SlideShare a Scribd company logo
1 of 2
Download to read offline
git essential commands 1/2
Working
Directory
Staging
area
Local
Repository
Remote
Repository
add
reset
checkout --
commit push
fetch
pull
commit -a
Create branch named <branch>
$ git branch <branch>
Switch to a <branch>
$ git checkout <branch>
Create and checkout a new branch
$ git checkout -b <branch>
List all branches
$ git branch -a
Delete a branch
$ git branch -D <branch>
Delete a remote branch
$ git push origin --delete <branch>
Branches
Merge <branch> into current branch
$ git merge <branch>
Merge
Unmodifying a modified File
$ git checkout -- [file]
Unstage a file
$ git reset [file]
Change last commit
$ git commit --amend
Revert
Push local changes to remote
$ git push <remote> <branch>
Get the latest changes (no merge)
$ git fetch <remote>
Fetch and merge last changes
$ git pull <remote> <branch>
List remote’s name and URL
$ git remote -v
Add a new remote
$ git remote add <name> <url>
Synchronize
Create a new local repo
$ git init
Clone existing repository
$ git clone <repo_url>
Create Repository
Add files to tracked / staged
$ git add file1 file2
$ git add .
List changed / new files on local repo
$ git status
List changes on tracked files
$ git diff
Commit
$ git commit -m "commit msg"
$ git commit -am "commit msg"
Show commit content
$ git show $id
Show entire history
$ git log
Local changes
master : default branch
origin: default remote
HEAD: current point
Basics
git additional commands 2/2
Method 1 (no commit)
Share change from $id1 to $id2
$ git diff $id1 $id2 > output.patch
To apply
$ git apply output.patch
Method 2 (with commit)
Generate patch for last 2 commits
$ git format-patch ~2
Apply patch
$ git am file.patch
Patching
Stash modification
$ git stash
Apply the modification back
$ git stash pop
Stash
Create Tag
$ git tag –a <tagName> –m "msg"
List Tags
$ git tag
Delete Tag
$ git tag -d <tagName>
Push Tag
$ git push <remote> --tags
$ git push <remote> <tagName>
Tagging
Who did what
$ git blame
Find in source code
$ git grep
Finding regressions
$ git bisect
Debugging
Global Ignore files
$ edit .gitignore
Configure aliases
$ git config --global alias.c "commit"
Use git help
$ git command --help
Others
To view merge conflicts
$ git diff
To discard conflicting patch
$ git reset --hard
$ git rebase --skip
After resolving conflig, merge with
$ git add [conflict_file]
$ git rebase --continue
Resolve merge conflicts
Apply a change introduced by a commit
$ git cherry-pick $id
Cherry pick
Rebase master content into current br
$ git rebase master
Interactively rebase current branch
$ git rebase –i <branch>
Rebase

More Related Content

What's hot

Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash CourseNilay Binjola
 
Storage Management in Linux OS.ppt
Storage Management in Linux OS.pptStorage Management in Linux OS.ppt
Storage Management in Linux OS.pptRakesh Kadu
 
Container Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, NetflixContainer Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, NetflixDocker, Inc.
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Version Control History and Git Basics
Version Control History and Git BasicsVersion Control History and Git Basics
Version Control History and Git BasicsSreedath N S
 
BT Güvenlik ve Kariyer Klavuzu
BT Güvenlik ve Kariyer KlavuzuBT Güvenlik ve Kariyer Klavuzu
BT Güvenlik ve Kariyer KlavuzuBGA Cyber Security
 
Top 5 Reasons To Consider SolarWinds IPAM Over Infoblox
Top 5 Reasons To Consider SolarWinds IPAM Over InfobloxTop 5 Reasons To Consider SolarWinds IPAM Over Infoblox
Top 5 Reasons To Consider SolarWinds IPAM Over InfobloxSolarWinds
 
Troubleshooting Provisioning Services Target Boot Processes
Troubleshooting Provisioning Services Target Boot ProcessesTroubleshooting Provisioning Services Target Boot Processes
Troubleshooting Provisioning Services Target Boot ProcessesDavid McGeough
 
Wp ipam infoblox
Wp ipam infobloxWp ipam infoblox
Wp ipam infobloxislamet
 
Group policy Best Practices
Group policy Best PracticesGroup policy Best Practices
Group policy Best PracticesRob Dunn
 
Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - GitCarlo Bernaschina
 
Treinamento git - Papos RBSDev
Treinamento git - Papos RBSDevTreinamento git - Papos RBSDev
Treinamento git - Papos RBSDevHélio Medeiros
 

What's hot (20)

Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Versioning avec Git
Versioning avec GitVersioning avec Git
Versioning avec Git
 
Storage Management in Linux OS.ppt
Storage Management in Linux OS.pptStorage Management in Linux OS.ppt
Storage Management in Linux OS.ppt
 
Container Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, NetflixContainer Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, Netflix
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Version Control History and Git Basics
Version Control History and Git BasicsVersion Control History and Git Basics
Version Control History and Git Basics
 
BT Güvenlik ve Kariyer Klavuzu
BT Güvenlik ve Kariyer KlavuzuBT Güvenlik ve Kariyer Klavuzu
BT Güvenlik ve Kariyer Klavuzu
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git and Github
Git and GithubGit and Github
Git and Github
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
Top 5 Reasons To Consider SolarWinds IPAM Over Infoblox
Top 5 Reasons To Consider SolarWinds IPAM Over InfobloxTop 5 Reasons To Consider SolarWinds IPAM Over Infoblox
Top 5 Reasons To Consider SolarWinds IPAM Over Infoblox
 
Troubleshooting Provisioning Services Target Boot Processes
Troubleshooting Provisioning Services Target Boot ProcessesTroubleshooting Provisioning Services Target Boot Processes
Troubleshooting Provisioning Services Target Boot Processes
 
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
 
Git basics
Git basicsGit basics
Git basics
 
Wp ipam infoblox
Wp ipam infobloxWp ipam infoblox
Wp ipam infoblox
 
Group policy Best Practices
Group policy Best PracticesGroup policy Best Practices
Group policy Best Practices
 
Introdução ao Git
Introdução ao GitIntrodução ao Git
Introdução ao Git
 
Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - Git
 
Github
GithubGithub
Github
 
Treinamento git - Papos RBSDev
Treinamento git - Papos RBSDevTreinamento git - Papos RBSDev
Treinamento git - Papos RBSDev
 

Similar to git essential commands

Similar to git essential commands (20)

Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
 
Did you git yet?
Did you git yet?Did you git yet?
Did you git yet?
 
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
 
Git
GitGit
Git
 
Brainly git basics workshop
Brainly git basics workshopBrainly git basics workshop
Brainly git basics workshop
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
 
Git cheat sheet with diagram-5.pdf
Git cheat sheet with diagram-5.pdfGit cheat sheet with diagram-5.pdf
Git cheat sheet with diagram-5.pdf
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 
Git
GitGit
Git
 
Git
GitGit
Git
 
git internals
git internalsgit internals
git internals
 
git - the basics
git - the basicsgit - the basics
git - the basics
 

Recently uploaded

Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 

Recently uploaded (20)

Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 

git essential commands

  • 1. git essential commands 1/2 Working Directory Staging area Local Repository Remote Repository add reset checkout -- commit push fetch pull commit -a Create branch named <branch> $ git branch <branch> Switch to a <branch> $ git checkout <branch> Create and checkout a new branch $ git checkout -b <branch> List all branches $ git branch -a Delete a branch $ git branch -D <branch> Delete a remote branch $ git push origin --delete <branch> Branches Merge <branch> into current branch $ git merge <branch> Merge Unmodifying a modified File $ git checkout -- [file] Unstage a file $ git reset [file] Change last commit $ git commit --amend Revert Push local changes to remote $ git push <remote> <branch> Get the latest changes (no merge) $ git fetch <remote> Fetch and merge last changes $ git pull <remote> <branch> List remote’s name and URL $ git remote -v Add a new remote $ git remote add <name> <url> Synchronize Create a new local repo $ git init Clone existing repository $ git clone <repo_url> Create Repository Add files to tracked / staged $ git add file1 file2 $ git add . List changed / new files on local repo $ git status List changes on tracked files $ git diff Commit $ git commit -m "commit msg" $ git commit -am "commit msg" Show commit content $ git show $id Show entire history $ git log Local changes master : default branch origin: default remote HEAD: current point Basics
  • 2. git additional commands 2/2 Method 1 (no commit) Share change from $id1 to $id2 $ git diff $id1 $id2 > output.patch To apply $ git apply output.patch Method 2 (with commit) Generate patch for last 2 commits $ git format-patch ~2 Apply patch $ git am file.patch Patching Stash modification $ git stash Apply the modification back $ git stash pop Stash Create Tag $ git tag –a <tagName> –m "msg" List Tags $ git tag Delete Tag $ git tag -d <tagName> Push Tag $ git push <remote> --tags $ git push <remote> <tagName> Tagging Who did what $ git blame Find in source code $ git grep Finding regressions $ git bisect Debugging Global Ignore files $ edit .gitignore Configure aliases $ git config --global alias.c "commit" Use git help $ git command --help Others To view merge conflicts $ git diff To discard conflicting patch $ git reset --hard $ git rebase --skip After resolving conflig, merge with $ git add [conflict_file] $ git rebase --continue Resolve merge conflicts Apply a change introduced by a commit $ git cherry-pick $id Cherry pick Rebase master content into current br $ git rebase master Interactively rebase current branch $ git rebase –i <branch> Rebase