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 ...
![Page 1: Git and GitHub · Git and GitHub : Key Git Concepts : Snapshots 3 / 10. Time Travel git checkout // go back to an earlier snapshot Resurrect the codebase](https://reader034.fdocuments.net/reader034/viewer/2022052408/5f0f80377e708231d4447971/html5/thumbnails/1.jpg)
Git and GitHub
Stephen P Levitt
School of Electrical and Information EngineeringUniversity of the Witwatersrand
2019
![Page 2: Git and GitHub · Git and GitHub : Key Git Concepts : Snapshots 3 / 10. Time Travel git checkout // go back to an earlier snapshot Resurrect the codebase](https://reader034.fdocuments.net/reader034/viewer/2022052408/5f0f80377e708231d4447971/html5/thumbnails/2.jpg)
Outline
1 Key Git ConceptsSnapshotsTime TravelBranchesParallel Universes
2 GitHub
Git and GitHub 1 / 10
![Page 3: Git and GitHub · Git and GitHub : Key Git Concepts : Snapshots 3 / 10. Time Travel git checkout // go back to an earlier snapshot Resurrect the codebase](https://reader034.fdocuments.net/reader034/viewer/2022052408/5f0f80377e708231d4447971/html5/thumbnails/3.jpg)
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
![Page 4: Git and GitHub · Git and GitHub : Key Git Concepts : Snapshots 3 / 10. Time Travel git checkout // go back to an earlier snapshot Resurrect the codebase](https://reader034.fdocuments.net/reader034/viewer/2022052408/5f0f80377e708231d4447971/html5/thumbnails/4.jpg)
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
![Page 5: Git and GitHub · Git and GitHub : Key Git Concepts : Snapshots 3 / 10. Time Travel git checkout // go back to an earlier snapshot Resurrect the codebase](https://reader034.fdocuments.net/reader034/viewer/2022052408/5f0f80377e708231d4447971/html5/thumbnails/5.jpg)
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
![Page 6: Git and GitHub · Git and GitHub : Key Git Concepts : Snapshots 3 / 10. Time Travel git checkout // go back to an earlier snapshot Resurrect the codebase](https://reader034.fdocuments.net/reader034/viewer/2022052408/5f0f80377e708231d4447971/html5/thumbnails/6.jpg)
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
![Page 7: Git and GitHub · Git and GitHub : Key Git Concepts : Snapshots 3 / 10. Time Travel git checkout // go back to an earlier snapshot Resurrect the codebase](https://reader034.fdocuments.net/reader034/viewer/2022052408/5f0f80377e708231d4447971/html5/thumbnails/7.jpg)
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
![Page 8: Git and GitHub · Git and GitHub : Key Git Concepts : Snapshots 3 / 10. Time Travel git checkout // go back to an earlier snapshot Resurrect the codebase](https://reader034.fdocuments.net/reader034/viewer/2022052408/5f0f80377e708231d4447971/html5/thumbnails/8.jpg)
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
![Page 9: Git and GitHub · Git and GitHub : Key Git Concepts : Snapshots 3 / 10. Time Travel git checkout // go back to an earlier snapshot Resurrect the codebase](https://reader034.fdocuments.net/reader034/viewer/2022052408/5f0f80377e708231d4447971/html5/thumbnails/9.jpg)
Apollo 11 Command and Lunar Module Guidance Systems
https://github.com/chrislgarry/Apollo-11
Git and GitHub : GitHub 8 / 10
![Page 10: Git and GitHub · Git and GitHub : Key Git Concepts : Snapshots 3 / 10. Time Travel git checkout // go back to an earlier snapshot Resurrect the codebase](https://reader034.fdocuments.net/reader034/viewer/2022052408/5f0f80377e708231d4447971/html5/thumbnails/10.jpg)
Quine Relay
https://github.com/mame/quine-relay
Git and GitHub : GitHub 9 / 10