SlideShare a Scribd company logo
“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

More Related Content

PPTX
GitLab.pptx
PPTX
Introduction git
PPTX
Introduction to Gitlab | Gitlab 101 | Training Session
PPTX
Github basics
PDF
Introduction to Git and GitHub
PDF
Introducing GitLab (September 2018)
PDF
Git training v10
PPTX
Git & GitLab
GitLab.pptx
Introduction git
Introduction to Gitlab | Gitlab 101 | Training Session
Github basics
Introduction to Git and GitHub
Introducing GitLab (September 2018)
Git training v10
Git & GitLab

What's hot (20)

PDF
Git and github 101
PPTX
GitHub Basics - Derek Bable
PDF
Git and git flow
PPTX
PPTX
Git Lab Introduction
PDF
Gitlab CI : Integration et Déploiement Continue
PPTX
Versioning avec Git
PPTX
PDF
git and github
PPTX
Git in 10 minutes
PPT
Git basic
PPTX
Présentation Git & GitHub
PDF
Tutoriel GIT
KEY
The everyday developer's guide to version control with Git
PDF
Introduction to GitHub Actions
PPTX
Git - Basic Crash Course
PDF
Introducing GitLab (June 2018)
PPTX
Source control
PPTX
Introduction to Git and GitHub Part 1
PPTX
Jenkins CI
Git and github 101
GitHub Basics - Derek Bable
Git and git flow
Git Lab Introduction
Gitlab CI : Integration et Déploiement Continue
Versioning avec Git
git and github
Git in 10 minutes
Git basic
Présentation Git & GitHub
Tutoriel GIT
The everyday developer's guide to version control with Git
Introduction to GitHub Actions
Git - Basic Crash Course
Introducing GitLab (June 2018)
Source control
Introduction to Git and GitHub Part 1
Jenkins CI
Ad

Similar to Version Control & Git (20)

PPTX
PPTX
Techoalien git
PPTX
Techoalien git
PPTX
Techoalien git
PDF
Git of every day
PDF
Getting some Git
PPTX
Git walkthrough
PPTX
Git 101 - An introduction to Version Control using Git
PPTX
Introduction to git, a version control system
PPTX
Git-ing out of your git messes
PPTX
Intro to git and git hub
PDF
Version control and GIT Primer
PDF
An Introduction to Git
PPSX
Advanced Web Development in PHP - Code Versioning and Branching with Git
KEY
Use git the proper way
PPTX
Git tutorial
PPTX
Git session Dropsolid.com
ODP
Introduction of Git
PDF
SVN 2 Git
PPT
Git Cards - Keynote Format
Techoalien git
Techoalien git
Techoalien git
Git of every day
Getting some Git
Git walkthrough
Git 101 - An introduction to Version Control using Git
Introduction to git, a version control system
Git-ing out of your git messes
Intro to git and git hub
Version control and GIT Primer
An Introduction to Git
Advanced Web Development in PHP - Code Versioning and Branching with Git
Use git the proper way
Git tutorial
Git session Dropsolid.com
Introduction of Git
SVN 2 Git
Git Cards - Keynote Format
Ad

Recently uploaded (20)

PPTX
Introduction to Knowledge Engineering Part 1
PPTX
Acceptance and paychological effects of mandatory extra coach I classes.pptx
PPTX
Moving the Public Sector (Government) to a Digital Adoption
PDF
Clinical guidelines as a resource for EBP(1).pdf
PPTX
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
PPT
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
PPTX
IB Computer Science - Internal Assessment.pptx
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PDF
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
PDF
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PDF
Introduction to Business Data Analytics.
PPTX
Major-Components-ofNKJNNKNKNKNKronment.pptx
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PDF
Lecture1 pattern recognition............
PPTX
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
Introduction to Knowledge Engineering Part 1
Acceptance and paychological effects of mandatory extra coach I classes.pptx
Moving the Public Sector (Government) to a Digital Adoption
Clinical guidelines as a resource for EBP(1).pdf
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
IB Computer Science - Internal Assessment.pptx
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
climate analysis of Dhaka ,Banglades.pptx
Business Acumen Training GuidePresentation.pptx
oil_refinery_comprehensive_20250804084928 (1).pptx
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
Introduction to Business Data Analytics.
Major-Components-ofNKJNNKNKNKNKronment.pptx
Data_Analytics_and_PowerBI_Presentation.pptx
Lecture1 pattern recognition............
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
STUDY DESIGN details- Lt Col Maksud (21).pptx

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