SlideShare une entreprise Scribd logo
1  sur  2
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances (20)

Shell programming
Shell programmingShell programming
Shell programming
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control System
 
Git
GitGit
Git
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
git - eine praktische Einführung
git - eine praktische Einführunggit - eine praktische Einführung
git - eine praktische Einführung
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
 
Learning git
Learning gitLearning git
Learning git
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training Session
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Version control
Version controlVersion control
Version control
 
Grokking opensource with github
Grokking opensource with githubGrokking opensource with github
Grokking opensource with github
 
Github basics
Github basicsGithub basics
Github basics
 
Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction
 
Git commands
Git commandsGit commands
Git commands
 
User Administration in Linux
User Administration in LinuxUser Administration in Linux
User Administration in Linux
 
Gitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTreeGitlab Training with GIT and SourceTree
Gitlab Training with GIT and SourceTree
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version Control
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Linux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell ScriptingLinux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell Scripting
 

Similaire à git essential commands

Similaire à git essential commands (20)

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
 
Linux GIT commands
Linux GIT commandsLinux GIT commands
Linux GIT commands
 

Dernier

Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
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
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
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
 
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
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
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
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
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
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 

Dernier (20)

Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
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...
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
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
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
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
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
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...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 

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