ݺߣ

ݺߣShare a Scribd company logo
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 remotes 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 Ca <tagName> Cm "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 Ci <branch>
Rebase

More Related Content

What's hot (20)

Git rebase
Git rebaseGit rebase
Git rebase
SitaPrajapati
?
Git l'essentielGit l'essentiel
Git l'essentiel
Riadh MNASRI
?
Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
?
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
Roland Emmanuel Salunga
?
Git advanced
Git advancedGit advanced
Git advanced
Peter Vandenabeele
?
汾 ʹGit & git hub
汾   ʹGit & git hub汾   ʹGit & git hub
汾 ʹGit & git hub
S
?
Tutorial GitTutorial Git
Tutorial Git
UCLouvain ACM Student Chapter
?
Git - Level 2
Git - Level 2Git - Level 2
Git - Level 2
?? ?
?
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicols Tourn
?
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
Safique Ahmed Faruque
?
Ҿٻ
ҾٻҾٻ
Ҿٻ
Max Ma
?
Git workflows presentation
Git workflows presentationGit workflows presentation
Git workflows presentation
Mack Hardy
?
S? d?ng GIT cho ng??i m?i b?t ??u (Ti?ng Vi?t)
S? d?ng GIT cho ng??i m?i b?t ??u (Ti?ng Vi?t)S? d?ng GIT cho ng??i m?i b?t ??u (Ti?ng Vi?t)
S? d?ng GIT cho ng??i m?i b?t ??u (Ti?ng Vi?t)
Thanh Bi
?
Git flowˤĤƤޤȤƤߤ
Git flowˤĤƤޤȤƤߤGit flowˤĤƤޤȤƤߤ
Git flowˤĤƤޤȤƤߤ
hiroyuki koga
?
Gi?i thi?u Git v m?t s? tnh n?ng c? b?n
Gi?i thi?u Git v m?t s? tnh n?ng c? b?nGi?i thi?u Git v m?t s? tnh n?ng c? b?n
Gi?i thi?u Git v m?t s? tnh n?ng c? b?n
Huy Nguyen Quang
?
Git   utilisation quotidienneGit   utilisation quotidienne
Git utilisation quotidienne
Sylvain Witmeyer
?
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
Jim Yeh
?
Git training
Git trainingGit training
Git training
eric7master
?
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
?
Version control system
Version control systemVersion control system
Version control system
Andrew Liu
?
Git l'essentielGit l'essentiel
Git l'essentiel
Riadh MNASRI
?
汾 ʹGit & git hub
汾   ʹGit & git hub汾   ʹGit & git hub
汾 ʹGit & git hub
S
?
Git - Level 2
Git - Level 2Git - Level 2
Git - Level 2
?? ?
?
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
Nicols Tourn
?
Git workflows presentation
Git workflows presentationGit workflows presentation
Git workflows presentation
Mack Hardy
?
S? d?ng GIT cho ng??i m?i b?t ??u (Ti?ng Vi?t)
S? d?ng GIT cho ng??i m?i b?t ??u (Ti?ng Vi?t)S? d?ng GIT cho ng??i m?i b?t ??u (Ti?ng Vi?t)
S? d?ng GIT cho ng??i m?i b?t ??u (Ti?ng Vi?t)
Thanh Bi
?
Gi?i thi?u Git v m?t s? tnh n?ng c? b?n
Gi?i thi?u Git v m?t s? tnh n?ng c? b?nGi?i thi?u Git v m?t s? tnh n?ng c? b?n
Gi?i thi?u Git v m?t s? tnh n?ng c? b?n
Huy Nguyen Quang
?
Git   utilisation quotidienneGit   utilisation quotidienne
Git utilisation quotidienne
Sylvain Witmeyer
?
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
Jim Yeh
?
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
?
Version control system
Version control systemVersion control system
Version control system
Andrew Liu
?

Similar to Git training cheat sheet (20)

Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
?
Did you git yet?
Did you git yet?Did you git yet?
Did you git yet?
Michael Fong
?
Get Good With Git
Get Good With GitGet Good With Git
Get Good With Git
Hoffman Lab
?
Git
GitGit
Git
AddWeb Solution Pvt. Ltd.
?
Brainly git basics workshop
Brainly git basics workshopBrainly git basics workshop
Brainly git basics workshop
?ukasz Lalik
?
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
jaehyok Song
?
Git cheatsheet
Git cheatsheetGit cheatsheet
Git cheatsheet
Weghlis Azzariou
?
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
NiranjanKumarGanjiku1
?
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
Mahmoud Said
?
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
vimukthirandika
?
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
Jae Nwawe
?
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
Augusto Gabriel Luna Bardales
?
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
Adeel Munir
?
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
leo_priv00
?
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
vartmp
?
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
srinathcox
?
Git
GitGit
Git
Maks Charuk
?
Git
GitGit
Git
Gustavo Barbosa
?
git internals
git internalsgit internals
git internals
Dennis Byrne
?
git - the basics
git - the basicsgit - the basics
git - the basics
Arnelle Balane
?

Recently uploaded (20)

A Brief Introduction About Raman Bhaumik
A Brief Introduction About Raman BhaumikA Brief Introduction About Raman Bhaumik
A Brief Introduction About Raman Bhaumik
Raman Bhaumik
?
Enscape Latest 2025 Crack Free Download
Enscape Latest 2025  Crack Free DownloadEnscape Latest 2025  Crack Free Download
Enscape Latest 2025 Crack Free Download
rnzu5cxw0y
?
Elastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - VirtualElastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - Virtual
Gon?alo Pereira
?
OutSystems User Group Utrecht February 2025.pdf
OutSystems User Group Utrecht February 2025.pdfOutSystems User Group Utrecht February 2025.pdf
OutSystems User Group Utrecht February 2025.pdf
mail496323
?
Online Software Testing Training Institute in Delhi Ncr
Online Software Testing Training Institute in Delhi NcrOnline Software Testing Training Institute in Delhi Ncr
Online Software Testing Training Institute in Delhi Ncr
Home
?
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost OptimizationNext-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
asmith539880
?
Build the future with Agentforce and Mulesoft
Build the future with Agentforce and  MulesoftBuild the future with Agentforce and  Mulesoft
Build the future with Agentforce and Mulesoft
GiulioPicchi
?
Minitool Partition Wizard Crack Free Download
Minitool Partition Wizard Crack Free DownloadMinitool Partition Wizard Crack Free Download
Minitool Partition Wizard Crack Free Download
v3r2eptd2q
?
SketchUp Pro Crack [2025]-Free Download?
SketchUp Pro Crack [2025]-Free Download?SketchUp Pro Crack [2025]-Free Download?
SketchUp Pro Crack [2025]-Free Download?
kiran10101khan
?
AI Agents and More:Build Your AI Assistans
AI Agents and More:Build Your AI AssistansAI Agents and More:Build Your AI Assistans
AI Agents and More:Build Your AI Assistans
HusseinMalikMammadli
?
iTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free DownloadiTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free Download
lr74xqnvuf
?
EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]
bhagasufyan
?
Account Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odooAccount Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odoo
AxisTechnolabs
?
Wondershare Filmora Crack Free Download
Wondershare Filmora  Crack Free DownloadWondershare Filmora  Crack Free Download
Wondershare Filmora Crack Free Download
zqeevcqb3t
?
Cybersecurity & Innovation: The Future of Mobile App Development
Cybersecurity & Innovation: The Future of Mobile App DevelopmentCybersecurity & Innovation: The Future of Mobile App Development
Cybersecurity & Innovation: The Future of Mobile App Development
iProgrammer Solutions Private Limited
?
20 Excel Shortcuts That Will Instantly Save You Hours.pdf
20 Excel Shortcuts That Will Instantly Save You Hours.pdf20 Excel Shortcuts That Will Instantly Save You Hours.pdf
20 Excel Shortcuts That Will Instantly Save You Hours.pdf
mohammadasim74
?
Why Hire Python Developers? Key Benefits for Your Business
Why Hire Python Developers? Key Benefits for Your BusinessWhy Hire Python Developers? Key Benefits for Your Business
Why Hire Python Developers? Key Benefits for Your Business
Mypcot Infotech
?
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP SolutionsWhy Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Absolute ERP
?
Wondershare Filmora 14.3.2 Crack + License Key Free Download
Wondershare Filmora 14.3.2 Crack + License Key Free DownloadWondershare Filmora 14.3.2 Crack + License Key Free Download
Wondershare Filmora 14.3.2 Crack + License Key Free Download
arshadkhokher01
?
Carousel - Five Key FinTech Trends for 2025
Carousel - Five Key FinTech Trends for 2025Carousel - Five Key FinTech Trends for 2025
Carousel - Five Key FinTech Trends for 2025
Anadea
?
A Brief Introduction About Raman Bhaumik
A Brief Introduction About Raman BhaumikA Brief Introduction About Raman Bhaumik
A Brief Introduction About Raman Bhaumik
Raman Bhaumik
?
Enscape Latest 2025 Crack Free Download
Enscape Latest 2025  Crack Free DownloadEnscape Latest 2025  Crack Free Download
Enscape Latest 2025 Crack Free Download
rnzu5cxw0y
?
Elastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - VirtualElastic Search Engineer Certification - Virtual
Elastic Search Engineer Certification - Virtual
Gon?alo Pereira
?
OutSystems User Group Utrecht February 2025.pdf
OutSystems User Group Utrecht February 2025.pdfOutSystems User Group Utrecht February 2025.pdf
OutSystems User Group Utrecht February 2025.pdf
mail496323
?
Online Software Testing Training Institute in Delhi Ncr
Online Software Testing Training Institute in Delhi NcrOnline Software Testing Training Institute in Delhi Ncr
Online Software Testing Training Institute in Delhi Ncr
Home
?
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost OptimizationNext-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
Next-Gen Procurement: Leveraging AI for Smarter Sourcing & Cost Optimization
asmith539880
?
Build the future with Agentforce and Mulesoft
Build the future with Agentforce and  MulesoftBuild the future with Agentforce and  Mulesoft
Build the future with Agentforce and Mulesoft
GiulioPicchi
?
Minitool Partition Wizard Crack Free Download
Minitool Partition Wizard Crack Free DownloadMinitool Partition Wizard Crack Free Download
Minitool Partition Wizard Crack Free Download
v3r2eptd2q
?
SketchUp Pro Crack [2025]-Free Download?
SketchUp Pro Crack [2025]-Free Download?SketchUp Pro Crack [2025]-Free Download?
SketchUp Pro Crack [2025]-Free Download?
kiran10101khan
?
AI Agents and More:Build Your AI Assistans
AI Agents and More:Build Your AI AssistansAI Agents and More:Build Your AI Assistans
AI Agents and More:Build Your AI Assistans
HusseinMalikMammadli
?
iTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free DownloadiTop VPN Latest Version 2025 Crack Free Download
iTop VPN Latest Version 2025 Crack Free Download
lr74xqnvuf
?
EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]EASEUS Partition Master Crack with License Code [Latest]
EASEUS Partition Master Crack with License Code [Latest]
bhagasufyan
?
Account Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odooAccount Cash Flow Statement Report Generate in odoo
Account Cash Flow Statement Report Generate in odoo
AxisTechnolabs
?
Wondershare Filmora Crack Free Download
Wondershare Filmora  Crack Free DownloadWondershare Filmora  Crack Free Download
Wondershare Filmora Crack Free Download
zqeevcqb3t
?
20 Excel Shortcuts That Will Instantly Save You Hours.pdf
20 Excel Shortcuts That Will Instantly Save You Hours.pdf20 Excel Shortcuts That Will Instantly Save You Hours.pdf
20 Excel Shortcuts That Will Instantly Save You Hours.pdf
mohammadasim74
?
Why Hire Python Developers? Key Benefits for Your Business
Why Hire Python Developers? Key Benefits for Your BusinessWhy Hire Python Developers? Key Benefits for Your Business
Why Hire Python Developers? Key Benefits for Your Business
Mypcot Infotech
?
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP SolutionsWhy Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Why Every Cables and Wires Manufacturer Needs a Cloud-Based ERP Solutions
Absolute ERP
?
Wondershare Filmora 14.3.2 Crack + License Key Free Download
Wondershare Filmora 14.3.2 Crack + License Key Free DownloadWondershare Filmora 14.3.2 Crack + License Key Free Download
Wondershare Filmora 14.3.2 Crack + License Key Free Download
arshadkhokher01
?
Carousel - Five Key FinTech Trends for 2025
Carousel - Five Key FinTech Trends for 2025Carousel - Five Key FinTech Trends for 2025
Carousel - Five Key FinTech Trends for 2025
Anadea
?

Git training cheat sheet

  • 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 remotes 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 Ca <tagName> Cm "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 Ci <branch> Rebase