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

PDF
Version Control & Git
Craig Smith
 
PDF
A Practical Introduction to git
Emanuele Olivetti
 
PDF
Git and github 101
Senthilkumar Gopal
 
KEY
The everyday developer's guide to version control with Git
E Carter
 
PDF
Github - Git Training Slides: Foundations
Lee Hanxue
 
PPTX
Introduction to git hub
Naveen Pandey
 
PPTX
Advanced Git Presentation By Swawibe
Md Swawibe Ul Alam
 
PDF
Introduction to Git and GitHub
Vikram SV
 
Version Control & Git
Craig Smith
 
A Practical Introduction to git
Emanuele Olivetti
 
Git and github 101
Senthilkumar Gopal
 
The everyday developer's guide to version control with Git
E Carter
 
Github - Git Training Slides: Foundations
Lee Hanxue
 
Introduction to git hub
Naveen Pandey
 
Advanced Git Presentation By Swawibe
Md Swawibe Ul Alam
 
Introduction to Git and GitHub
Vikram SV
 

What's hot (20)

PDF
Git Version Control System
KMS Technology
 
PDF
Git basics
GHARSALLAH Mohamed
 
PDF
Advanced Git Tutorial
Sage Sharp
 
PPTX
Git in 10 minutes
Safique Ahmed Faruque
 
PDF
Git training v10
Skander Hamza
 
PPTX
Git One Day Training Notes
glen_a_smith
 
PDF
Git & GitHub for Beginners
Sébastien Saunier
 
PDF
Git Started With Git
Nick Quaranto
 
PDF
Git real slides
Lucas Couto
 
PDF
はじめてのGit forデザイナー&コーダー
Saeko Yamamoto
 
PDF
はじめようGit
techscore
 
PPTX
Git - Basic Crash Course
Nilay Binjola
 
PDF
Version Control with Git
Luigi De Russis
 
PPTX
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 
PDF
github-actions.pdf
AbhaymithraReddy1
 
PDF
いつやるの?Git入門
Masakazu Matsushita
 
PDF
Intro to Git and GitHub
Panagiotis Papadopoulos
 
PPTX
Basic Git Intro
Yoad Snapir
 
PPTX
Git and git workflow best practice
Majid Hosseini
 
Git Version Control System
KMS Technology
 
Git basics
GHARSALLAH Mohamed
 
Advanced Git Tutorial
Sage Sharp
 
Git in 10 minutes
Safique Ahmed Faruque
 
Git training v10
Skander Hamza
 
Git One Day Training Notes
glen_a_smith
 
Git & GitHub for Beginners
Sébastien Saunier
 
Git Started With Git
Nick Quaranto
 
Git real slides
Lucas Couto
 
はじめてのGit forデザイナー&コーダー
Saeko Yamamoto
 
はじめようGit
techscore
 
Git - Basic Crash Course
Nilay Binjola
 
Version Control with Git
Luigi De Russis
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 
github-actions.pdf
AbhaymithraReddy1
 
いつやるの?Git入門
Masakazu Matsushita
 
Intro to Git and GitHub
Panagiotis Papadopoulos
 
Basic Git Intro
Yoad Snapir
 
Git and git workflow best practice
Majid Hosseini
 
Ad

Similar to Version Control & Git (20)

PPTX
Git
Parag Gupta
 
PPTX
Techoalien git
Aditya Tiwari
 
PPTX
Techoalien git
Aditya Tiwari
 
PPTX
Techoalien git
Aditya Tiwari
 
PDF
Git of every day
Alan Descoins
 
PDF
Getting some Git
BADR
 
PPTX
Git walkthrough
Bimal Jain
 
PPTX
Git 101 - An introduction to Version Control using Git
John Tighe
 
PPTX
Introduction to git, a version control system
Kumaresh Chandra Baruri
 
PPTX
Git-ing out of your git messes
Katie Sylor-Miller
 
PPTX
Intro to git and git hub
Venkat Malladi
 
PDF
Version control and GIT Primer
saadulde
 
PDF
An Introduction to Git
Hiroyuki Vincent Yamazaki
 
PPSX
Advanced Web Development in PHP - Code Versioning and Branching with Git
Rasan Samarasinghe
 
KEY
Use git the proper way
Jaime Buelta
 
PPTX
Git tutorial
Ananth Kumar
 
PPTX
Git session Dropsolid.com
dropsolid
 
ODP
Introduction of Git
Wayne Chen
 
PDF
SVN 2 Git
Marco De Stefano
 
PPT
Git Cards - Keynote Format
Adam Lowe
 
Techoalien git
Aditya Tiwari
 
Techoalien git
Aditya Tiwari
 
Techoalien git
Aditya Tiwari
 
Git of every day
Alan Descoins
 
Getting some Git
BADR
 
Git walkthrough
Bimal Jain
 
Git 101 - An introduction to Version Control using Git
John Tighe
 
Introduction to git, a version control system
Kumaresh Chandra Baruri
 
Git-ing out of your git messes
Katie Sylor-Miller
 
Intro to git and git hub
Venkat Malladi
 
Version control and GIT Primer
saadulde
 
An Introduction to Git
Hiroyuki Vincent Yamazaki
 
Advanced Web Development in PHP - Code Versioning and Branching with Git
Rasan Samarasinghe
 
Use git the proper way
Jaime Buelta
 
Git tutorial
Ananth Kumar
 
Git session Dropsolid.com
dropsolid
 
Introduction of Git
Wayne Chen
 
SVN 2 Git
Marco De Stefano
 
Git Cards - Keynote Format
Adam Lowe
 
Ad

Recently uploaded (20)

PPTX
HSE WEEKLY REPORT for dummies and lazzzzy.pptx
ahmedibrahim691723
 
PPTX
Data-Users-in-Database-Management-Systems (1).pptx
dharmik832021
 
PPTX
Presentation (1) (1).pptx k8hhfftuiiigff
karthikjagath2005
 
PDF
TIC ACTIVIDAD 1geeeeeeeeeeeeeeeeeeeeeeeeeeeeeer3.pdf
Thais Ruiz
 
PPTX
Introduction to Data Analytics and Data Science
KavithaCIT
 
PPTX
White Blue Simple Modern Enhancing Sales Strategy Presentation_20250724_21093...
RamNeymarjr
 
PPTX
Presentation on animal welfare a good topic
kidscream385
 
PPTX
Pipeline Automatic Leak Detection for Water Distribution Systems
Sione Palu
 
PPT
Real Life Application of Set theory, Relations and Functions
manavparmar205
 
PPTX
Introduction-to-Python-Programming-Language (1).pptx
dhyeysapariya
 
PPTX
Multiscale Segmentation of Survey Respondents: Seeing the Trees and the Fores...
Sione Palu
 
PPTX
Introduction to computer chapter one 2017.pptx
mensunmarley
 
PPTX
Fluvial_Civilizations_Presentation (1).pptx
alisslovemendoza7
 
PDF
717629748-Databricks-Certified-Data-Engineer-Professional-Dumps-by-Ball-21-03...
pedelli41
 
PDF
Technical Writing Module-I Complete Notes.pdf
VedprakashArya13
 
PDF
SUMMER INTERNSHIP REPORT[1] (AutoRecovered) (6) (1).pdf
pandeydiksha814
 
PPTX
World-population.pptx fire bunberbpeople
umutunsalnsl4402
 
PDF
Blitz Campinas - Dia 24 de maio - Piettro.pdf
fabigreek
 
PPTX
Data Security Breach: Immediate Action Plan
varmabhuvan266
 
PPT
From Vision to Reality: The Digital India Revolution
Harsh Bharvadiya
 
HSE WEEKLY REPORT for dummies and lazzzzy.pptx
ahmedibrahim691723
 
Data-Users-in-Database-Management-Systems (1).pptx
dharmik832021
 
Presentation (1) (1).pptx k8hhfftuiiigff
karthikjagath2005
 
TIC ACTIVIDAD 1geeeeeeeeeeeeeeeeeeeeeeeeeeeeeer3.pdf
Thais Ruiz
 
Introduction to Data Analytics and Data Science
KavithaCIT
 
White Blue Simple Modern Enhancing Sales Strategy Presentation_20250724_21093...
RamNeymarjr
 
Presentation on animal welfare a good topic
kidscream385
 
Pipeline Automatic Leak Detection for Water Distribution Systems
Sione Palu
 
Real Life Application of Set theory, Relations and Functions
manavparmar205
 
Introduction-to-Python-Programming-Language (1).pptx
dhyeysapariya
 
Multiscale Segmentation of Survey Respondents: Seeing the Trees and the Fores...
Sione Palu
 
Introduction to computer chapter one 2017.pptx
mensunmarley
 
Fluvial_Civilizations_Presentation (1).pptx
alisslovemendoza7
 
717629748-Databricks-Certified-Data-Engineer-Professional-Dumps-by-Ball-21-03...
pedelli41
 
Technical Writing Module-I Complete Notes.pdf
VedprakashArya13
 
SUMMER INTERNSHIP REPORT[1] (AutoRecovered) (6) (1).pdf
pandeydiksha814
 
World-population.pptx fire bunberbpeople
umutunsalnsl4402
 
Blitz Campinas - Dia 24 de maio - Piettro.pdf
fabigreek
 
Data Security Breach: Immediate Action Plan
varmabhuvan266
 
From Vision to Reality: The Digital India Revolution
Harsh Bharvadiya
 

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