To introduce and motivate some best practice around version control and Git.
Resources:
https://en.wikipedia.org/wiki/Version_control
https://git-scm.com/
https://try.github.io
http://rogerdudler.github.io/git-guide/
http://ohshitgit.com/
https://www.atlassian.com/git/tutorials
https://www.datacamp.com/courses/introduction-to-git-for-data-science
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.
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