SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
“Ways of Working” - Royal Mail Data Science Team Seminar
https://git-scm/blog
Dr. Jason Byrne
Jan. 2018
1
Ways of Working | Version Control & Git
Royal Mail | GBI | Data Science
Team Seminar
Dr. Jason Byrne
Jan. 2018
2
Collaboration
Due	Diligence
Track	changes
Backup
Store	versions
Coordination
Agile
Version Control: Motivation
3
Version Control: Development Branches
4
Distributed Version Control System
5
https://git-scm.com
5
git-scm.com/blog6
HEAD

is the snapshot of your last commit, or the pointer to the current branch reference (repository).
Index

is the snapshot of your next commit (staging area).
Working Directory

is your scratch space used to easily modify file content.
git-scm.com/blog7
HEAD

is the snapshot of your last commit, or the pointer to the current branch reference (repository).
Index

is the snapshot of your next commit (staging area).
Working Directory

is your scratch space used to easily modify file content.
git add
git commit
git commit -a
git-scm.com/blog8
HEAD

is the snapshot of your last commit, or the pointer to the current branch reference.
Index

is the snapshot of your next commit (staging area).
Working Directory

is your scratch space used to easily modify file content.
git init
git-scm.com/blog9
HEAD

is the snapshot of your last commit, or the pointer to the current branch reference.
Index

is the snapshot of your next commit (staging area).
Working Directory

is your scratch space used to easily modify file content.
git-scm.com/blog10
HEAD

is the snapshot of your last commit, or the pointer to the current branch reference.
Index

is the snapshot of your next commit (staging area).
Working Directory

is your scratch space used to easily modify file content.
git-scm.com/blog11
HEAD

is the snapshot of your last commit, or the pointer to the current branch reference.
Index

is the snapshot of your next commit (staging area).
Working Directory

is your scratch space used to easily modify file content.
git-scm.com/blog12
HEAD

is the snapshot of your last commit, or the pointer to the current branch reference.
Index

is the snapshot of your next commit (staging area).
Working Directory

is your scratch space used to easily modify file content.
git-scm.com/blog13
HEAD

is the snapshot of your last commit, or the pointer to the current branch reference.
Index

is the snapshot of your next commit (staging area).
Working Directory

is your scratch space used to easily modify file content.
git-scm.com/blog14
HEAD

is the snapshot of your last commit, or the pointer to the current branch reference.
Index

is the snapshot of your next commit (staging area).
Working Directory

is your scratch space used to easily modify file content.
git-scm.com/blog15
git reset

moves what HEAD points to (and updates the Index with the contents of the tree HEAD now points to).
--soft 

with this flag, moving HEAD is the only thing reset does, essentially undoing your last commit.
git commit --amend

this is an option that simplifies changing the last commit instead of needing to use reset.
git-scm.com/blog16
git reset

moves what HEAD points to and updates the Index with the contents of the tree HEAD now points to.
--mixed 

with this flag, reset stops after moving HEAD and updating the index. This is also the default.
git add & git commit 

this reset undid your last commit and unstaged everything. Any edits need to be added & committed again.
git-scm.com/blog17
git reset

moves what HEAD points to and updates the Index with the contents of the tree HEAD now points to.
--hard 

with this flag, reset moves HEAD, updates the index, and makes the Working Directory look like the Index.
git reflog 

ordered list of the commits that HEAD has pointed to (as opposed to log which traverses HEAD’s ancestry).
git-scm.com/blog18
git reset HEAD~# [filename]

updates part of the Index to match the version from the specified commit (where the tree HEAD now points to).
--soft|mixed|hard 

no effect as the staged snapshot (Index) is always updated and Working Directory is never updated.
git add [filename] 

is essentially the opposite command, as the reset basically unstages the file.
git-scm.com/blog19
git reset HEAD~# [filename]

updates part of the Index to match the version from the specified commit (where the tree HEAD now points to).
--soft|mixed|hard 

no effect as the staged snapshot (Index) is always updated and Working Directory is never updated.
git add [filename] 

is essentially the opposite command, as the reset basically unstages the file.
git-scm.com/blog20
git reset HEAD~# [filename]

updates part of the Index to match the version from the specified commit.
--soft|mixed|hard 

no effect as the staged snapshot (Index) is always updated and Working Directory is never updated.
git add [filename]

is essentially the opposite command, as the reset basically unstages the file.
git-scm.com/blog21
git reset example to demonstrate squashing unimportant commits to clean up history.

moves what HEAD points to (and updates the Index with the contents of the tree HEAD now points to).
--soft 

with this flag, moving HEAD is the only thing reset does, essentially undoing your last commit.
git commit 

commits the latest changes staged in Index.
38eb946
git-scm.com/blog22
git reset example to demonstrate squashing unimportant commits to clean up history.

moves what HEAD points to (and updates the Index with the contents of the tree HEAD now points to).
--soft 

with this flag, moving HEAD is the only thing reset does, essentially undoing your last commit.
git commit 

commits the latest changes staged in Index.
--soft
git-scm.com/blog23
git reset example to demonstrate squashing unimportant commits to clean up history.

moves what HEAD points to (and updates the Index with the contents of the tree HEAD now points to).
--soft 

with this flag, moving HEAD is the only thing reset does, essentially undoing your last commit.
git commit 

commits the latest changes staged in Index.
68aef35
git-scm.com/blog24
git reset --hard [branch]

moves the branch HEAD points to, updates the Index, and makes the Working Directory look like the Index.
git checkout [branch]

moves HEAD to point at the branch and updates the Index and Working Directory accordingly.
git branch 

shows the current branch HEAD points at.
25
26
git init [repo name]

initialise a git repository.
git status

show status of git repository.
git log [filename]

shows current HEAD and its ancestry / commit log accessible from the git refs.
git reflog [show HEAD | --all | otherbranch]

reference logs track when git refs were updated in the local repository. (Doesn’t traverse HEAD’s
ancestry.)
git add [filename]

add file to staging area.
git commit -m “[message]”

commit file with reference message.
git show [ID | HEAD~#]

show the history of a specific commit identified by 40-character hexadecimal string.
git annotate [filename]

show the details of the last change to a file.
git diff -r HEAD [filename] 

show the difference between a file and its latest commit.
git diff ID1..ID2 [ID is SHA/hash | HEAD~#] or git diff branch1..branch2

show the difference between two commits or branches.
git clean

clean up untracked files or directories.
git config --[system | global | local]

configuration settings for every user / every project / specific project, & set user credentials.
summary
26
27
git checkout -- [filename]

discard changes to file before staging (i.e. before adding them to staging area for commit).
git checkout ID [filename]

restore the previous version at the specified hash ID of a file or directory.
git checkout [branch name]

change to branch (i.e. move where HEAD is pointing and update working trees accordingly).
git reset HEAD [filename]

reset the file or directory to the state it was last staged.
git merge [source] [destination]

merge the source branch with the destination branch - resolving conflicts as necessary.
git clone URL [repo name]

clone a git repository from the URL which can point to a web address (http://) or a file location (file://).
git remote -v

list the names of the repository’s remote configurations & URLs.
git pull remote branch

pull changes from the remote repository and merge them into the current branch of your local
repository.
git push remote branch

pushes the contents of your branch into a branch with the same name in the associated remote
repository.
git fetch remote branch

pull changes from the remote repository to your local repository.
git stash

stash changes in the remote repository rather than pushing them, useful to switch branches during
development.
summary
27

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Git real slides
Git real slidesGit real slides
Git real slides
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git Terminologies
Git TerminologiesGit Terminologies
Git Terminologies
 
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
 
Version Control System - Git
Version Control System - GitVersion Control System - Git
Version Control System - Git
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
git and github
git and githubgit and github
git and github
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
 
Introduction to Git and Github
Introduction to Git and GithubIntroduction to Git and Github
Introduction to Git and Github
 
GIT INTRODUCTION
GIT INTRODUCTIONGIT INTRODUCTION
GIT INTRODUCTION
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Github basics
Github basicsGithub basics
Github basics
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Introduction to GitHub
Introduction to GitHubIntroduction to GitHub
Introduction to GitHub
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 

Semelhante a Version Control & Git

Semelhante a Version Control & Git (20)

Git basic
Git basicGit basic
Git basic
 
Git SCM
Git SCMGit SCM
Git SCM
 
Atlassian git cheatsheet
Atlassian git cheatsheetAtlassian git cheatsheet
Atlassian git cheatsheet
 
Git like a pro EDD18 - Full edition
Git like a pro EDD18 - Full editionGit like a pro EDD18 - Full edition
Git like a pro EDD18 - Full edition
 
Git-ing out of your git messes
Git-ing out of  your git messesGit-ing out of  your git messes
Git-ing out of your git messes
 
Git training
Git trainingGit training
Git training
 
GIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control SystemGIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control System
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 
Git slides
Git slidesGit slides
Git slides
 
SVN 2 Git
SVN 2 GitSVN 2 Git
SVN 2 Git
 
GIT Basics
GIT BasicsGIT Basics
GIT Basics
 
Collaborative development with Git | Workshop
Collaborative development with Git | WorkshopCollaborative development with Git | Workshop
Collaborative development with Git | Workshop
 
Git cheatsheet
Git cheatsheetGit cheatsheet
Git cheatsheet
 
Git commands
Git commandsGit commands
Git commands
 
Git undo
Git undoGit undo
Git undo
 
Exprimiendo GIT
Exprimiendo GITExprimiendo GIT
Exprimiendo GIT
 
Git rewriting git history
Git   rewriting git  historyGit   rewriting git  history
Git rewriting git history
 
Git commands
Git commandsGit commands
Git commands
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
 

Último

Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxolyaivanovalion
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 

Último (20)

Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptx
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 

Version Control & Git

  • 1. “Ways of Working” - Royal Mail Data Science Team Seminar https://git-scm/blog Dr. Jason Byrne Jan. 2018 1 Ways of Working | Version Control & Git Royal Mail | GBI | Data Science Team Seminar Dr. Jason Byrne Jan. 2018
  • 6. git-scm.com/blog6 HEAD is the snapshot of your last commit, or the pointer to the current branch reference (repository). Index is the snapshot of your next commit (staging area). Working Directory is your scratch space used to easily modify file content.
  • 7. git-scm.com/blog7 HEAD is the snapshot of your last commit, or the pointer to the current branch reference (repository). Index is the snapshot of your next commit (staging area). Working Directory is your scratch space used to easily modify file content. git add git commit git commit -a
  • 8. git-scm.com/blog8 HEAD is the snapshot of your last commit, or the pointer to the current branch reference. Index is the snapshot of your next commit (staging area). Working Directory is your scratch space used to easily modify file content. git init
  • 9. git-scm.com/blog9 HEAD is the snapshot of your last commit, or the pointer to the current branch reference. Index is the snapshot of your next commit (staging area). Working Directory is your scratch space used to easily modify file content.
  • 10. git-scm.com/blog10 HEAD is the snapshot of your last commit, or the pointer to the current branch reference. Index is the snapshot of your next commit (staging area). Working Directory is your scratch space used to easily modify file content.
  • 11. git-scm.com/blog11 HEAD is the snapshot of your last commit, or the pointer to the current branch reference. Index is the snapshot of your next commit (staging area). Working Directory is your scratch space used to easily modify file content.
  • 12. git-scm.com/blog12 HEAD is the snapshot of your last commit, or the pointer to the current branch reference. Index is the snapshot of your next commit (staging area). Working Directory is your scratch space used to easily modify file content.
  • 13. git-scm.com/blog13 HEAD is the snapshot of your last commit, or the pointer to the current branch reference. Index is the snapshot of your next commit (staging area). Working Directory is your scratch space used to easily modify file content.
  • 14. git-scm.com/blog14 HEAD is the snapshot of your last commit, or the pointer to the current branch reference. Index is the snapshot of your next commit (staging area). Working Directory is your scratch space used to easily modify file content.
  • 15. git-scm.com/blog15 git reset moves what HEAD points to (and updates the Index with the contents of the tree HEAD now points to). --soft with this flag, moving HEAD is the only thing reset does, essentially undoing your last commit. git commit --amend this is an option that simplifies changing the last commit instead of needing to use reset.
  • 16. git-scm.com/blog16 git reset moves what HEAD points to and updates the Index with the contents of the tree HEAD now points to. --mixed with this flag, reset stops after moving HEAD and updating the index. This is also the default. git add & git commit this reset undid your last commit and unstaged everything. Any edits need to be added & committed again.
  • 17. git-scm.com/blog17 git reset moves what HEAD points to and updates the Index with the contents of the tree HEAD now points to. --hard with this flag, reset moves HEAD, updates the index, and makes the Working Directory look like the Index. git reflog ordered list of the commits that HEAD has pointed to (as opposed to log which traverses HEAD’s ancestry).
  • 18. git-scm.com/blog18 git reset HEAD~# [filename] updates part of the Index to match the version from the specified commit (where the tree HEAD now points to). --soft|mixed|hard no effect as the staged snapshot (Index) is always updated and Working Directory is never updated. git add [filename] is essentially the opposite command, as the reset basically unstages the file.
  • 19. git-scm.com/blog19 git reset HEAD~# [filename] updates part of the Index to match the version from the specified commit (where the tree HEAD now points to). --soft|mixed|hard no effect as the staged snapshot (Index) is always updated and Working Directory is never updated. git add [filename] is essentially the opposite command, as the reset basically unstages the file.
  • 20. git-scm.com/blog20 git reset HEAD~# [filename] updates part of the Index to match the version from the specified commit. --soft|mixed|hard no effect as the staged snapshot (Index) is always updated and Working Directory is never updated. git add [filename] is essentially the opposite command, as the reset basically unstages the file.
  • 21. git-scm.com/blog21 git reset example to demonstrate squashing unimportant commits to clean up history. moves what HEAD points to (and updates the Index with the contents of the tree HEAD now points to). --soft with this flag, moving HEAD is the only thing reset does, essentially undoing your last commit. git commit commits the latest changes staged in Index. 38eb946
  • 22. git-scm.com/blog22 git reset example to demonstrate squashing unimportant commits to clean up history. moves what HEAD points to (and updates the Index with the contents of the tree HEAD now points to). --soft with this flag, moving HEAD is the only thing reset does, essentially undoing your last commit. git commit commits the latest changes staged in Index. --soft
  • 23. git-scm.com/blog23 git reset example to demonstrate squashing unimportant commits to clean up history. moves what HEAD points to (and updates the Index with the contents of the tree HEAD now points to). --soft with this flag, moving HEAD is the only thing reset does, essentially undoing your last commit. git commit commits the latest changes staged in Index. 68aef35
  • 24. git-scm.com/blog24 git reset --hard [branch] moves the branch HEAD points to, updates the Index, and makes the Working Directory look like the Index. git checkout [branch] moves HEAD to point at the branch and updates the Index and Working Directory accordingly. git branch shows the current branch HEAD points at.
  • 25. 25
  • 26. 26 git init [repo name] initialise a git repository. git status show status of git repository. git log [filename] shows current HEAD and its ancestry / commit log accessible from the git refs. git reflog [show HEAD | --all | otherbranch] reference logs track when git refs were updated in the local repository. (Doesn’t traverse HEAD’s ancestry.) git add [filename] add file to staging area. git commit -m “[message]” commit file with reference message. git show [ID | HEAD~#] show the history of a specific commit identified by 40-character hexadecimal string. git annotate [filename] show the details of the last change to a file. git diff -r HEAD [filename] show the difference between a file and its latest commit. git diff ID1..ID2 [ID is SHA/hash | HEAD~#] or git diff branch1..branch2 show the difference between two commits or branches. git clean clean up untracked files or directories. git config --[system | global | local] configuration settings for every user / every project / specific project, & set user credentials. summary 26
  • 27. 27 git checkout -- [filename] discard changes to file before staging (i.e. before adding them to staging area for commit). git checkout ID [filename] restore the previous version at the specified hash ID of a file or directory. git checkout [branch name] change to branch (i.e. move where HEAD is pointing and update working trees accordingly). git reset HEAD [filename] reset the file or directory to the state it was last staged. git merge [source] [destination] merge the source branch with the destination branch - resolving conflicts as necessary. git clone URL [repo name] clone a git repository from the URL which can point to a web address (http://) or a file location (file://). git remote -v list the names of the repository’s remote configurations & URLs. git pull remote branch pull changes from the remote repository and merge them into the current branch of your local repository. git push remote branch pushes the contents of your branch into a branch with the same name in the associated remote repository. git fetch remote branch pull changes from the remote repository to your local repository. git stash stash changes in the remote repository rather than pushing them, useful to switch branches during development. summary 27