SlideShare a Scribd company logo
$ git branch
$ git logs
$ git fetch
$ git status
GIT
CHEAT
SHEET
SETUP & INIT
Configuring user information,
initializing and cloning repositories.
STAGE & SNAPSHOT
Working with snapshots and the
Git staging area.
$ git init $ git status
$ git add [file]
Add a file as it looks now to your
next commit (stage).
Local Copy of the
Repository
Remote
Repository at [URL]
Local Copy of the
Repository
$ git clone [url]
Retrieve an entire repository from
a hosted location via URL.
</>
git clone [URL]
</>
git clone [URL]
Working
Directory
git add [file]
Staging
Area
(Stage)
Initialize an existing directory as a
Git repository.
Show modified files in working directory,
staged for your next commit.
Normal Directory Git Repository
git init Git Status
Working
Directory
Staged
Snapshot
Unstaged
Snapshot
Git Cheatsheet
01
$ git reset [file]
git diff --staged
$ git commit -m “[descriptive message]”
Commit your staged content as a
new commit snapshot.
$ git diff
Diff of what is changed but not staged
Unstage a file while retaining the
changes in working directory.
Diff of what is staged but not
yet commited.
Working
Directory
git add [file]
Staging
Area
(Stage)
git reset [file]
(Unstage)
Staging
Area
Working
Directory
git diff
=
Staging
Area
Commit
History
git diff --staged
=
HEAD
Working
Directory
Staging
Area
Git Repository
(Commit History)
git commit
git add
BRANCH & MERGE
Isolating work in branches, changing
context, and integrating changes.
$ git branch
List your branches. A * will appear next to
the currently active branch.
Branch 1
Branch 2
*Main Branch
Git Cheatsheet
02
$ git merge [branch]
$ git log
Add a file as it looks now to your
next commit (stage).
$ git branch [branch-name]
Create a new branch at the
current commit.
Merge the specified branchʼs history
into the current one.
$ git checkout
Switch to another branch and check it
out into your working directory.
[branch-name]
Branch 2
Main Branch
git branch
[branch-name]
git checkout Branch_1
*Branch_1
Main Branch
Branch_1
*Main Branch
Main Branch
Branch 2
git merge
New Feature
git log
Git Logs
Git Repository
commit 21a67
Author : xyz
Date: Mon May 16 16:03:16 2022
Commit Message
commit fb555
Author : ABC
Date: Tue May 17 09:05:45 2022
Commit Message
commit 3ecd3
Author : XYZ
Date: Sun May 22 19:45:34 2022
Commit Message
commit 21a67
commit fb555
commit 3ecd3
Git Cheatsheet
03
INSPECT & COMPARE
Configuring user information,
initializing and cloning repositories.
$ git log branchB..branchA $ git diff branchB...branchA
$ git show [SHA]
Show any object in Git in
human-readable format.
$ git log --follow [file]
Show the commits that changed file,
even across renames.
Show the commits on branchA that
are not on branchB.
Show the diff of what is in branchA
that is not in branchB.
git log
branchB
...
branchA
Git Repository
branchB branchA
Git Logs
commit 181a9
Author : XYZ
Date: Mon May 16 16:03:16 2022
Commit Message
commit c7eaf
Author : ABC
Date: Tue May 17 09:05:45 2022
Commit Message
commit 181a9
commit c7eaf
gitdiff
branchB...branchA
branchA
branchB
commit 715c3
git show 715c3
commit 715c3
Author : XYZ
Date: Mon May 16 16:03:16 2022
Commit Message
File1
File1 Changes
File2
File2 Changes
...
Git Cheatsheet
04
TRACKING PATH CHANGES
Versioning file removes and
path changes.
$ git rm [file]
$ git log --stat -M
Show all commit logs with indication
of any paths that moved.
Delete the file from the project and
stage the removal for commit.
+
Git Repository
git rm [file]
(Stage the removal)
$ git mv [existing-path] [new-path]
Change an existing file path and
stage the move.
+
Git Repository
git mv [file]
(Stage the removal)
IGNORING PATTERNS
Preventing unintentional staging
or commiting of files.
logs/
*.notes
pattern*/
Save a file with desired patterns as
.gitignore with either direct string matches
or wildcard globs.
logs/
*.notes
pattern*/
.gitignore
$ git config --global core.excludesfile [file]
System wide ignore pattern for all
local repositories
Git Cheatsheet
05
$ git fetch [alias]
Fetch down all the branches from
that Git remote.
SHARE & UPDATE
Retrieving updates from another
repository and updating local repos.
$ git remote add [alias] [url]
$ git merge [alias]/[branch]
$ git push [alias] [branch]
Transmit local branch commits to
the remote repository branch.
Add a git URL as an alias.
Merge a remote branch into your current
branch to bring it up to date.
Local Git
Repository
Remote Git
Repository at [URL]
git remote add
[alias] [URL]
local/main
remote/main
new merge commit
Local Repository
Remote Repository
merge
git push
after merge
Main
origin/main
new merge
commit
Local Repository
Main
Remote Repository
git merge origin/main
after merge
Main
origin/main
Local Repository
Main
Remote Repository
git fetch origin/main
Git Cheatsheet
06
$ git reset --hard [commit]
$ git pull
Fetch and merge any commits from
the tracking remote branch.
Clear staging area, rewrite working
tree from specified commit.
local/main
remote origin/main
new merge
commit
Local Repository
after merge
git pull
REWRITE HISTORY
Rewriting branches, updating
commits and clearing history.
$ git rebase [branch]
Apply any commits of the current
branch ahead of specified one.
main
Feature
git rebase
TEMPORARY COMMITS
Temporarily store modified, tracked
files in order to change branches.
$ git stash
Save modified and staged changes.
head
Rewriting Staging Index
& Working Directory
git reset --hard HEAD~1
head
Working Directory
(Unstaged Changes)
git stash
Staged Changes
Git Cheatsheet
07
$ git stash list
List stack-order of stashed file changes.
Working
Directory
git stash
stash@(0): WIP on master: fd3aab8 done
git stash
stash@(1): WIP on master: fd3aab8 done
git stash
stash@(2): WIP on master: fd3aab8 done
git stash list
$ git stash pop
Write working from the top of
the stash stack.
Stash List
stash@{0}
stash@{1}
stash@{2}
stash@{3}
stash@{3}
Apply
git stash pop
Working
Directory
$ git stash drop
Discard the changes from the top
of the stash stack.
Stash List
stash@{0}
stash@{1}
stash@{2}
stash@{3}
stash@{3}
git stash drop
(Discard)
Git Cheatsheet
08

More Related Content

What's hot

Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
Prawesh Shrestha
 
Unix
UnixUnix
Unix
Erm78
 
Linux
LinuxLinux
TP Git avancé DevoxxFR 2018 (exercices)
TP Git avancé DevoxxFR 2018 (exercices)TP Git avancé DevoxxFR 2018 (exercices)
TP Git avancé DevoxxFR 2018 (exercices)
Jérôme Tamborini
 
Flappy Bird Tutorial
Flappy Bird TutorialFlappy Bird Tutorial
Flappy Bird Tutorial
Oluwaseye Ayinla
 
Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt
onu9
 
Integración Continua con Gitlab + Fastlane
Integración Continua con Gitlab + FastlaneIntegración Continua con Gitlab + Fastlane
Integración Continua con Gitlab + Fastlane
Jesús Martín Alonso
 
Fsmo roles
Fsmo rolesFsmo roles
Fsmo roles
Chinmoy Jena
 
Fragment
Fragment Fragment
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
sudhir singh yadav
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
Kandarp Tiwari
 
User management
User managementUser management
User management
Mufaddal Haidermota
 
Unix Programming Lab
Unix Programming LabUnix Programming Lab
Unix Programming Lab
Neil Mathew
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
Prianka Padmanaban
 
Computer Graphics Practical
Computer Graphics PracticalComputer Graphics Practical
Computer Graphics PracticalNeha Sharma
 
CS8461 Operating System Lab Manual S.Selvi
CS8461 Operating System Lab Manual S.SelviCS8461 Operating System Lab Manual S.Selvi
CS8461 Operating System Lab Manual S.Selvi
SELVI SIVAPERUMAL
 
File permission in linux
File permission in linuxFile permission in linux
File permission in linux
Prakash Poudel
 
Dos command for hackers
Dos command for hackersDos command for hackers
Dos command for hackers
Mozaaic Cyber Security
 
User and groups administrator
User  and  groups administratorUser  and  groups administrator
User and groups administrator
Aisha Talat
 

What's hot (20)

Introduction to fragments in android
Introduction to fragments in androidIntroduction to fragments in android
Introduction to fragments in android
 
Unix
UnixUnix
Unix
 
Linux
LinuxLinux
Linux
 
TP Git avancé DevoxxFR 2018 (exercices)
TP Git avancé DevoxxFR 2018 (exercices)TP Git avancé DevoxxFR 2018 (exercices)
TP Git avancé DevoxxFR 2018 (exercices)
 
Flappy Bird Tutorial
Flappy Bird TutorialFlappy Bird Tutorial
Flappy Bird Tutorial
 
Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt
 
Integración Continua con Gitlab + Fastlane
Integración Continua con Gitlab + FastlaneIntegración Continua con Gitlab + Fastlane
Integración Continua con Gitlab + Fastlane
 
Fsmo roles
Fsmo rolesFsmo roles
Fsmo roles
 
Fragment
Fragment Fragment
Fragment
 
Linux File System
Linux File SystemLinux File System
Linux File System
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
User management
User managementUser management
User management
 
Unix Programming Lab
Unix Programming LabUnix Programming Lab
Unix Programming Lab
 
Computer graphics
Computer graphics   Computer graphics
Computer graphics
 
Computer Graphics Practical
Computer Graphics PracticalComputer Graphics Practical
Computer Graphics Practical
 
CS8461 Operating System Lab Manual S.Selvi
CS8461 Operating System Lab Manual S.SelviCS8461 Operating System Lab Manual S.Selvi
CS8461 Operating System Lab Manual S.Selvi
 
File permission in linux
File permission in linuxFile permission in linux
File permission in linux
 
Dos command for hackers
Dos command for hackersDos command for hackers
Dos command for hackers
 
User and groups administrator
User  and  groups administratorUser  and  groups administrator
User and groups administrator
 

Similar to Git cheat sheet with diagram-5.pdf

Git Developer Cheatsheet
Git Developer CheatsheetGit Developer Cheatsheet
Git Developer CheatsheetAbdul Basit
 
Git cheatsheet
Git cheatsheetGit cheatsheet
Git cheatsheet
Weghlis Azzariou
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
srinathcox
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
DSC GVP
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheetjaehyok Song
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
Abdul Basit
 
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
leo_priv00
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheetvartmp
 
Github git-cheat-sheet
Github git-cheat-sheetGithub git-cheat-sheet
Github git-cheat-sheet
Adeel Munir
 
Did you git yet?
Did you git yet?Did you git yet?
Did you git yet?
Michael Fong
 
Git slides
Git slidesGit slides
Git slides
Nanyak S
 
Git foundation
Git foundationGit foundation
Git foundation
Wee Keat Chin
 
Git cheat-sheet-education
Git cheat-sheet-educationGit cheat-sheet-education
Git cheat-sheet-education
Avitesh Kesharwani
 
test
testtest
test
zwned
 
Git cheat-sheet-education
Git cheat-sheet-educationGit cheat-sheet-education
Git cheat-sheet-education
ssuser0bad24
 
Techmoneyguide
TechmoneyguideTechmoneyguide
Techmoneyguide
Rockstartssl
 
Git github
Git githubGit github
Git github
Anurag Deb
 

Similar to Git cheat sheet with diagram-5.pdf (20)

Git Developer Cheatsheet
Git Developer CheatsheetGit Developer Cheatsheet
Git Developer Cheatsheet
 
Git cheatsheet
Git cheatsheetGit cheatsheet
Git cheatsheet
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
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
 
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
 
Did you git yet?
Did you git yet?Did you git yet?
Did you git yet?
 
Git slides
Git slidesGit slides
Git slides
 
Git foundation
Git foundationGit foundation
Git foundation
 
Git cheat-sheet-education
Git cheat-sheet-educationGit cheat-sheet-education
Git cheat-sheet-education
 
test
testtest
test
 
Git cheat-sheet-education
Git cheat-sheet-educationGit cheat-sheet-education
Git cheat-sheet-education
 
Techmoneyguide
TechmoneyguideTechmoneyguide
Techmoneyguide
 
Git github
Git githubGit github
Git github
 
Gittalk
GittalkGittalk
Gittalk
 

Recently uploaded

ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
obonagu
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
zwunae
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
ssuser7dcef0
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
bhadouriyakaku
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
AIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdfAIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdf
RicletoEspinosa1
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 

Recently uploaded (20)

ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
AIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdfAIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 

Git cheat sheet with diagram-5.pdf

  • 1. $ git branch $ git logs $ git fetch $ git status GIT CHEAT SHEET
  • 2. SETUP & INIT Configuring user information, initializing and cloning repositories. STAGE & SNAPSHOT Working with snapshots and the Git staging area. $ git init $ git status $ git add [file] Add a file as it looks now to your next commit (stage). Local Copy of the Repository Remote Repository at [URL] Local Copy of the Repository $ git clone [url] Retrieve an entire repository from a hosted location via URL. </> git clone [URL] </> git clone [URL] Working Directory git add [file] Staging Area (Stage) Initialize an existing directory as a Git repository. Show modified files in working directory, staged for your next commit. Normal Directory Git Repository git init Git Status Working Directory Staged Snapshot Unstaged Snapshot Git Cheatsheet 01
  • 3. $ git reset [file] git diff --staged $ git commit -m “[descriptive message]” Commit your staged content as a new commit snapshot. $ git diff Diff of what is changed but not staged Unstage a file while retaining the changes in working directory. Diff of what is staged but not yet commited. Working Directory git add [file] Staging Area (Stage) git reset [file] (Unstage) Staging Area Working Directory git diff = Staging Area Commit History git diff --staged = HEAD Working Directory Staging Area Git Repository (Commit History) git commit git add BRANCH & MERGE Isolating work in branches, changing context, and integrating changes. $ git branch List your branches. A * will appear next to the currently active branch. Branch 1 Branch 2 *Main Branch Git Cheatsheet 02
  • 4. $ git merge [branch] $ git log Add a file as it looks now to your next commit (stage). $ git branch [branch-name] Create a new branch at the current commit. Merge the specified branchʼs history into the current one. $ git checkout Switch to another branch and check it out into your working directory. [branch-name] Branch 2 Main Branch git branch [branch-name] git checkout Branch_1 *Branch_1 Main Branch Branch_1 *Main Branch Main Branch Branch 2 git merge New Feature git log Git Logs Git Repository commit 21a67 Author : xyz Date: Mon May 16 16:03:16 2022 Commit Message commit fb555 Author : ABC Date: Tue May 17 09:05:45 2022 Commit Message commit 3ecd3 Author : XYZ Date: Sun May 22 19:45:34 2022 Commit Message commit 21a67 commit fb555 commit 3ecd3 Git Cheatsheet 03
  • 5. INSPECT & COMPARE Configuring user information, initializing and cloning repositories. $ git log branchB..branchA $ git diff branchB...branchA $ git show [SHA] Show any object in Git in human-readable format. $ git log --follow [file] Show the commits that changed file, even across renames. Show the commits on branchA that are not on branchB. Show the diff of what is in branchA that is not in branchB. git log branchB ... branchA Git Repository branchB branchA Git Logs commit 181a9 Author : XYZ Date: Mon May 16 16:03:16 2022 Commit Message commit c7eaf Author : ABC Date: Tue May 17 09:05:45 2022 Commit Message commit 181a9 commit c7eaf gitdiff branchB...branchA branchA branchB commit 715c3 git show 715c3 commit 715c3 Author : XYZ Date: Mon May 16 16:03:16 2022 Commit Message File1 File1 Changes File2 File2 Changes ... Git Cheatsheet 04
  • 6. TRACKING PATH CHANGES Versioning file removes and path changes. $ git rm [file] $ git log --stat -M Show all commit logs with indication of any paths that moved. Delete the file from the project and stage the removal for commit. + Git Repository git rm [file] (Stage the removal) $ git mv [existing-path] [new-path] Change an existing file path and stage the move. + Git Repository git mv [file] (Stage the removal) IGNORING PATTERNS Preventing unintentional staging or commiting of files. logs/ *.notes pattern*/ Save a file with desired patterns as .gitignore with either direct string matches or wildcard globs. logs/ *.notes pattern*/ .gitignore $ git config --global core.excludesfile [file] System wide ignore pattern for all local repositories Git Cheatsheet 05
  • 7. $ git fetch [alias] Fetch down all the branches from that Git remote. SHARE & UPDATE Retrieving updates from another repository and updating local repos. $ git remote add [alias] [url] $ git merge [alias]/[branch] $ git push [alias] [branch] Transmit local branch commits to the remote repository branch. Add a git URL as an alias. Merge a remote branch into your current branch to bring it up to date. Local Git Repository Remote Git Repository at [URL] git remote add [alias] [URL] local/main remote/main new merge commit Local Repository Remote Repository merge git push after merge Main origin/main new merge commit Local Repository Main Remote Repository git merge origin/main after merge Main origin/main Local Repository Main Remote Repository git fetch origin/main Git Cheatsheet 06
  • 8. $ git reset --hard [commit] $ git pull Fetch and merge any commits from the tracking remote branch. Clear staging area, rewrite working tree from specified commit. local/main remote origin/main new merge commit Local Repository after merge git pull REWRITE HISTORY Rewriting branches, updating commits and clearing history. $ git rebase [branch] Apply any commits of the current branch ahead of specified one. main Feature git rebase TEMPORARY COMMITS Temporarily store modified, tracked files in order to change branches. $ git stash Save modified and staged changes. head Rewriting Staging Index & Working Directory git reset --hard HEAD~1 head Working Directory (Unstaged Changes) git stash Staged Changes Git Cheatsheet 07
  • 9. $ git stash list List stack-order of stashed file changes. Working Directory git stash stash@(0): WIP on master: fd3aab8 done git stash stash@(1): WIP on master: fd3aab8 done git stash stash@(2): WIP on master: fd3aab8 done git stash list $ git stash pop Write working from the top of the stash stack. Stash List stash@{0} stash@{1} stash@{2} stash@{3} stash@{3} Apply git stash pop Working Directory $ git stash drop Discard the changes from the top of the stash stack. Stash List stash@{0} stash@{1} stash@{2} stash@{3} stash@{3} git stash drop (Discard) Git Cheatsheet 08