SlideShare a Scribd company logo
Learn about Git
Gorav Singal
https://www.gyanblog.com
Introduction
• Git is a Source code version control software.
• launched in 2008, By 2019 it had over 100
million repos.
• Made by Linus Torvalds, who is creator of
Linux Kernel.
• Every developer has a local copy with the full
history of repository
• Lot of features which require Deep learning
curve
• GUI often doesn’t expose all the
functionality
Bonus
• You can use github.com for any of your test
projects
• Free for personal use
• You can keep private projects as well.
Recently it became available
• You can host a static website on Github.com
for free.
Git GUI
Software
• Github Desktop
• Source-tree
Limited functionality in each. But,
works well for daily work.
Demo for Creating
Repo?
Flat folder structure
Getting the
Code
• Git clone
git@git.corp.adobe.com:tessa-
hubble-
integration/hubble_vulns.git
• Download code as zip
• Clone specific branch
git clone –b <branch>
git@git.corp../..vulns.git
• Clone history upto specific depth
level
• git clone --branch tag repo
Lifecycle OR
Stages in Git
Learn Git - For Beginners and Intermediate levels
Learn Git - For Beginners and Intermediate levels
Basic
Commands
• git add <file> (add, update, delete,
move)
• git add . (all untracked file to staging
area)
• Git status
• Git commit
• Git commit –m message
• Git push origin <branch>
• Git branch <branch>
• Git checkout
• Git log
• Git diff
• Git merge
• Git stash
Git Branch
• Create
• Git branch <branch name>
• Git checkout –b <branch name>
• Switching
• Git checkout <branch name>
• Merge
• Git merge <branch name>
• Delete
• Git branch -d <branch name>
• Push
• Git push origin
Pull Request
• Graphical overview of changes
• You can discuss about your changes
• Code review in git portal itself
• Incorporate Review comments, commit again
Git log
• Git log
• Git log –abbrev-commit
• Git log –oneline –graph –decorate
• Git log id1…id2
• Git log –since=“4 days ago”
• Git log -- <file>
• Git show <commit id>
Git diff
• By default, show diff between staged and
unstaged files only
• Git diff HEAD (between local and
Head(remtote))
• Git diff –staged HEAD (between stage
and remote)
• Git diff id1 id2 (between two commits)
• Git diff HEAD HEAD^1 (latest and latest-
1)
• Git diff branch1 branch2
Git Stash
• Git stash (Only tracked files)
• Git stash –u (for untracked files)
• Git stash save “message about stash”
• Git stash apply
• Git stash list
• Git stash pop
• Git stash pop stash@{3}
• Git stash show
• Git stash branch <branch-name> stash@{2}
• Git stash drop stash@{1}
• Git stash clear
Git tag
• Git tag <tagname>
• Git tag –a v1.2 –m “message”
• Git tag
• Git tag –a v1.1 <commit id>
• Git push v1.1
• Git checkout v1.1
• Git tag –d v1.1
• Tag points to a commit.
• What happen if you update a commit or remove
a commit to which tag points?
Git Pull
• Git fetch + git merge
• Git pull --rebase
Git Merge, Rebase
git checkout feature
git merge master
git checkout feature
git rebase master
Feature Branching Strategy
Release Branch Strategy
Hotfix
Git reset
• git checkout <your branch>
• git reset HEAD~2
• Moves your head to specified commit
• Dangerous
• Should not use in public branches
• Should use in private work/branch
• Alter commit history
Git revert
• git checkout hotfix
• git revert HEAD~2
• Safe
• Should be used for public branches
• Well commit history
Cherry-pick
• Pick some awesome data structure or feature from another branch to
working branch
• Hot fix is needed. Fix is available in some feature branch
• Feature branch never merged, but have some awesome code.
• Git cherry-pick <commit id>
Security
• Restrict who can commit, read
• Restrict who can merge
• Restrict minimum number of code
reviews
CI Support/git
hooks
• Local trigger/Server trigger
• Trigger something on every commit or PR
Best Practices
• No direct commit in Master/Stage branches
• Person with high privileges can skip all security checks.
• Always take a pull before pushing changes
• Put restriction who can commit to your code
• Restrict N number of code reviews before merge
• Write good commit message
• Clean your commit history before merge
• Have a good code review
• Have a .gitignore file
• Review your files before a blind commit
Questions
References
• https://www.gyanblog.com/gyan/practical-guide-how-work-git-basic-
commands-workflows/
• https://www.gyanblog.com/gyan/practical-guide-how-git-log-command/
• https://www.gyanblog.com/gyan/practical-guide-better-understanding-git-
diff/
• https://www.gyanblog.com/gyan/practical-guide-git-best-practices/
• https://www.gyanblog.com/gyan/effective-git-code-branching-strategy/
• https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud
Ad

More Related Content

What's hot (20)

Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Lukas Fittl
 
HacktoberFest-Git&GitHub
HacktoberFest-Git&GitHubHacktoberFest-Git&GitHub
HacktoberFest-Git&GitHub
GDSCIIITBbsr
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
Anil Wadghule
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
Krunal Doshi
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHub
DSCVSSUT
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Rueful Robin
 
Git n git hub
Git n git hubGit n git hub
Git n git hub
Jiwon Baek
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
Naveen Pandey
 
Git Tutorial
Git TutorialGit Tutorial
Git Tutorial
Moshe Kaplan
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
GoogleDevelopersStud1
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
聖文 鄭
 
Introduction to git administration
Introduction to git administrationIntroduction to git administration
Introduction to git administration
Shawn Doyle
 
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
msohn
 
Git with bitbucket
Git with bitbucketGit with bitbucket
Git with bitbucket
Suhas Shivaram
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015
mwrather
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
Emanuele Olivetti
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
Arthur Shvetsov
 
Intro to Git & GitHub
Intro to Git & GitHubIntro to Git & GitHub
Intro to Git & GitHub
Google Developer Students Club NIT Silchar
 
Git presentation
Git presentationGit presentation
Git presentation
Sai Kumar Satapathy
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucket
azwildcat
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
Lukas Fittl
 
HacktoberFest-Git&GitHub
HacktoberFest-Git&GitHubHacktoberFest-Git&GitHub
HacktoberFest-Git&GitHub
GDSCIIITBbsr
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
Krunal Doshi
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHub
DSCVSSUT
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Rueful Robin
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
Naveen Pandey
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
聖文 鄭
 
Introduction to git administration
Introduction to git administrationIntroduction to git administration
Introduction to git administration
Shawn Doyle
 
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
Code Review with Git and Gerrit - Devoxx 2011 - Tools in Action - 2011-11-14
msohn
 
Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015Introduction to Git, DrupalCamp LA 2015
Introduction to Git, DrupalCamp LA 2015
mwrather
 
A Practical Introduction to git
A Practical Introduction to gitA Practical Introduction to git
A Practical Introduction to git
Emanuele Olivetti
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
Arthur Shvetsov
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucket
azwildcat
 

Similar to Learn Git - For Beginners and Intermediate levels (20)

Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptx
Abdul Salam
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
Nguyen Van Hung
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
Jim Yeh
 
11 git version control
11 git version control11 git version control
11 git version control
Wasim Alatrash
 
Git workshop - University of Moratuwa, Department of Computer Science and Eng...
Git workshop - University of Moratuwa, Department of Computer Science and Eng...Git workshop - University of Moratuwa, Department of Computer Science and Eng...
Git workshop - University of Moratuwa, Department of Computer Science and Eng...
WSO2
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
Kishor Kumar
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
Robert Lee-Cann
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
Betclic Everest Group Tech Team
 
Git tips and tricks
Git   tips and tricksGit   tips and tricks
Git tips and tricks
Chris Ballance
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
Bimal Jain
 
Git is a distributed version control system .
Git is a distributed version control system .Git is a distributed version control system .
Git is a distributed version control system .
HELLOWorld889594
 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to Git
Muhil Vannan
 
tech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptxtech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptx
ashishraulin
 
Git and Github and how can we leverage in Daily Coding
Git and Github and how can we leverage in Daily CodingGit and Github and how can we leverage in Daily Coding
Git and Github and how can we leverage in Daily Coding
wrdxtevhxiseyweuiw
 
Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHub
Kim Moir
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
BigBlueHat
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
tnscharishma
 
Advanted git
Advanted git Advanted git
Advanted git
Sahil Gupta
 
Introduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptxIntroduction to git and githhub with practicals.pptx
Introduction to git and githhub with practicals.pptx
Abdul Salam
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
Jim Yeh
 
11 git version control
11 git version control11 git version control
11 git version control
Wasim Alatrash
 
Git workshop - University of Moratuwa, Department of Computer Science and Eng...
Git workshop - University of Moratuwa, Department of Computer Science and Eng...Git workshop - University of Moratuwa, Department of Computer Science and Eng...
Git workshop - University of Moratuwa, Department of Computer Science and Eng...
WSO2
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
Kishor Kumar
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
Robert Lee-Cann
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
Bimal Jain
 
Git is a distributed version control system .
Git is a distributed version control system .Git is a distributed version control system .
Git is a distributed version control system .
HELLOWorld889594
 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to Git
Muhil Vannan
 
tech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptxtech winter break workshop on git &git hub.pptx
tech winter break workshop on git &git hub.pptx
ashishraulin
 
Git and Github and how can we leverage in Daily Coding
Git and Github and how can we leverage in Daily CodingGit and Github and how can we leverage in Daily Coding
Git and Github and how can we leverage in Daily Coding
wrdxtevhxiseyweuiw
 
Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHub
Kim Moir
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
BigBlueHat
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
tnscharishma
 
Ad

Recently uploaded (20)

Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Rock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning JourneyRock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning Journey
Lynda Kane
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Rock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning JourneyRock, Paper, Scissors: An Apex Map Learning Journey
Rock, Paper, Scissors: An Apex Map Learning Journey
Lynda Kane
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Ad

Learn Git - For Beginners and Intermediate levels

  • 1. Learn about Git Gorav Singal https://www.gyanblog.com
  • 2. Introduction • Git is a Source code version control software. • launched in 2008, By 2019 it had over 100 million repos. • Made by Linus Torvalds, who is creator of Linux Kernel. • Every developer has a local copy with the full history of repository • Lot of features which require Deep learning curve • GUI often doesn’t expose all the functionality
  • 3. Bonus • You can use github.com for any of your test projects • Free for personal use • You can keep private projects as well. Recently it became available • You can host a static website on Github.com for free.
  • 4. Git GUI Software • Github Desktop • Source-tree Limited functionality in each. But, works well for daily work.
  • 5. Demo for Creating Repo? Flat folder structure
  • 6. Getting the Code • Git clone [email protected]:tessa- hubble- integration/hubble_vulns.git • Download code as zip • Clone specific branch git clone –b <branch> [email protected]../..vulns.git • Clone history upto specific depth level • git clone --branch tag repo
  • 10. Basic Commands • git add <file> (add, update, delete, move) • git add . (all untracked file to staging area) • Git status • Git commit • Git commit –m message • Git push origin <branch> • Git branch <branch> • Git checkout • Git log • Git diff • Git merge • Git stash
  • 11. Git Branch • Create • Git branch <branch name> • Git checkout –b <branch name> • Switching • Git checkout <branch name> • Merge • Git merge <branch name> • Delete • Git branch -d <branch name> • Push • Git push origin
  • 12. Pull Request • Graphical overview of changes • You can discuss about your changes • Code review in git portal itself • Incorporate Review comments, commit again
  • 13. Git log • Git log • Git log –abbrev-commit • Git log –oneline –graph –decorate • Git log id1…id2 • Git log –since=“4 days ago” • Git log -- <file> • Git show <commit id>
  • 14. Git diff • By default, show diff between staged and unstaged files only • Git diff HEAD (between local and Head(remtote)) • Git diff –staged HEAD (between stage and remote) • Git diff id1 id2 (between two commits) • Git diff HEAD HEAD^1 (latest and latest- 1) • Git diff branch1 branch2
  • 15. Git Stash • Git stash (Only tracked files) • Git stash –u (for untracked files) • Git stash save “message about stash” • Git stash apply • Git stash list • Git stash pop • Git stash pop stash@{3} • Git stash show • Git stash branch <branch-name> stash@{2} • Git stash drop stash@{1} • Git stash clear
  • 16. Git tag • Git tag <tagname> • Git tag –a v1.2 –m “message” • Git tag • Git tag –a v1.1 <commit id> • Git push v1.1 • Git checkout v1.1 • Git tag –d v1.1 • Tag points to a commit. • What happen if you update a commit or remove a commit to which tag points?
  • 17. Git Pull • Git fetch + git merge • Git pull --rebase
  • 18. Git Merge, Rebase git checkout feature git merge master git checkout feature git rebase master
  • 22. Git reset • git checkout <your branch> • git reset HEAD~2 • Moves your head to specified commit • Dangerous • Should not use in public branches • Should use in private work/branch • Alter commit history
  • 23. Git revert • git checkout hotfix • git revert HEAD~2 • Safe • Should be used for public branches • Well commit history
  • 24. Cherry-pick • Pick some awesome data structure or feature from another branch to working branch • Hot fix is needed. Fix is available in some feature branch • Feature branch never merged, but have some awesome code. • Git cherry-pick <commit id>
  • 25. Security • Restrict who can commit, read • Restrict who can merge • Restrict minimum number of code reviews
  • 26. CI Support/git hooks • Local trigger/Server trigger • Trigger something on every commit or PR
  • 27. Best Practices • No direct commit in Master/Stage branches • Person with high privileges can skip all security checks. • Always take a pull before pushing changes • Put restriction who can commit to your code • Restrict N number of code reviews before merge • Write good commit message • Clean your commit history before merge • Have a good code review • Have a .gitignore file • Review your files before a blind commit
  • 29. References • https://www.gyanblog.com/gyan/practical-guide-how-work-git-basic- commands-workflows/ • https://www.gyanblog.com/gyan/practical-guide-how-git-log-command/ • https://www.gyanblog.com/gyan/practical-guide-better-understanding-git- diff/ • https://www.gyanblog.com/gyan/practical-guide-git-best-practices/ • https://www.gyanblog.com/gyan/effective-git-code-branching-strategy/ • https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud