Git and GitHub · Git and GitHub : Key Git Concepts : Snapshots 3 / 10. Time Travel git checkout ...
Transcript of Git and GitHub · Git and GitHub : Key Git Concepts : Snapshots 3 / 10. Time Travel git checkout ...
Git and GitHub
Stephen P Levitt
School of Electrical and Information EngineeringUniversity of the Witwatersrand
2019
Outline
1 Key Git ConceptsSnapshotsTime TravelBranchesParallel Universes
2 GitHub
Git and GitHub 1 / 10
Snapshots
git commit // take a snapshotgit log // view IDs and descriptions of past snapshots
Snapshots of the codebase are created on demand with a commitA commit stores:
the changes to all the files under version controlthe date and time the snapshot was taken, and the authora message describing the work that is contained in the snapshota reference to the parent commit object
Each commit has a unique ID generated by a cryptographic hash function
Git and GitHub : Key Git Concepts : Snapshots 2 / 10
Snapshots continued
commit f0032b7b2a549c6b6d5cd84e0258e3c54711dcaa (HEAD -> master,origin/master)
Author: Stephen Levitt <[email protected]>Commit: Stephen Levitt <[email protected]>
Added some videos, comments to slides, new google car image
Included some video content. At the moment videos are not embeddedin the slides. Added comments to slides about talking points.These should be converted into proper notes.
Code in a snapshot can never be changed — immutable
Git and GitHub : Key Git Concepts : Snapshots 3 / 10
Time Travel
git checkout <abbreviated commit hash> // go back to an earliersnapshot
Resurrect the codebase at an earlier point in time — work is never lostSuitable for code inspection; branching required for storing any changes made tothe checked-out commit
Git and GitHub : Key Git Concepts : Time Travel 4 / 10
Branches
git branch <branch name> // create a new branchgit checkout <branch name> // move to the tip of the new branchgit merge <branch name> // merge the named branch into the branch
you are on
Short-lived branches are used forexperimentation and feature developmentEventually will be merged back intomaster or another dev branchMerges take place between two local branches or two remote branchesRemote branch merge required for code review on GitHub, via a pull requestFast-forward merging will occur if the branches being merged have not diverged
Git and GitHub : Key Git Concepts : Branches 5 / 10
Parallel Universes
Enables collaboration
git push // push local branch toremote
git pull // fetch remote branch andmerge into local; you pull codetowards you
Often each developer has a local repo which is synced with a shared remote repo(on GitHub for example); local branches track upstream (remote) branchesMain branch in local repo is called master; main branch in remote repo is calledorigin / master
Git and GitHub : Key Git Concepts : Parallel Universes 6 / 10
GitHub
Web-based Git hosting serviceWorld’s largest host of open-source code - 57 million repositories; used extensivelyin industry as wellProvides additional features such as code review, repo analytics, and lightweightproject management tools
Git and GitHub : GitHub 7 / 10
Apollo 11 Command and Lunar Module Guidance Systems
https://github.com/chrislgarry/Apollo-11
Git and GitHub : GitHub 8 / 10
Quine Relay
https://github.com/mame/quine-relay
Git and GitHub : GitHub 9 / 10