peter ogden and josh levine. motivation high level overview walk through the common operations ...
TRANSCRIPT
![Page 1: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/1.jpg)
Git: Introduction and Tutorial
Peter Ogden and Josh Levine
![Page 2: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/2.jpg)
Motivation High level overview Walk through the common operations How not to break things (too badly)
What to expect
![Page 3: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/3.jpg)
Detailed usage Command reference Internal functionality Advanced topics
What not to expect
![Page 4: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/4.jpg)
Do you…◦ Use more than one computer?◦ Collaborate?◦ Break stuff in unknown ways?◦ Backup?
Why source control?
![Page 5: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/5.jpg)
Widely used in the open source community◦ Linux, KDE, LLVM, Github
Supported natively in CAS Available for every platform Wide variety of tools and interfaces Offline working
Why Git?
![Page 6: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/6.jpg)
What is Git?
![Page 7: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/7.jpg)
Visible files◦ Current state of the folder
Hidden history◦ Collection of commits◦ Reference to the current commit
What is a Git repository?
![Page 8: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/8.jpg)
Contains a diff Has metadata
◦ Message◦ Time◦ Author
Linked to previous commit Commit ID is the hash of everything
What is a commit?
![Page 9: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/9.jpg)
![Page 10: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/10.jpg)
All communication is explicit Push to put things in a remote repository Pull to bring things from a remote repository
How do repositories communicate?
![Page 11: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/11.jpg)
DEMONSTRATION 1Setting up a new repository
![Page 12: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/12.jpg)
Terminology◦ Tracked – files known to git◦ Index – files to be committed◦ Staged – changes in the index
Committing Work
addingUntrackedUnstaged committingIn index Committed
![Page 13: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/13.jpg)
DEMONSTRATION 2Committing and pushing
![Page 14: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/14.jpg)
Two stages in pulling◦ Fetch all commits from the remote server◦ Update the local version with remote changes
Conflicts◦ Someone else may have changed the file◦ Git will try to apply all changes◦ May require help
Pulling and merging
![Page 15: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/15.jpg)
Pushing
![Page 16: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/16.jpg)
Pushing
The push will fail - “non fast-forward”
![Page 17: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/17.jpg)
Pushing
![Page 18: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/18.jpg)
DEMONSTRATION 3Collaborative working
![Page 19: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/19.jpg)
Only add files you mean to◦ thumbs.db◦ .trash◦ vim temporary files
Failing to pull before a push Make sure everything is committed before
pulling
Common Pitfalls
![Page 20: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/20.jpg)
Questions
![Page 21: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/21.jpg)
Set name and email◦ git config --global user.email [email protected]
◦ git config --global user.name “Peter Ogden”
Initialise an empty repository◦ git init
Committing work
Getting started
![Page 22: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/22.jpg)
Create remote repository - e.g. on ee-casgit Add remote server
◦ git remote add origin git@ee-casgit:pko11_test Push to server
◦ git push origin HEAD
Pushing to a remote server
Remote to push to
Commit to push
![Page 23: Peter Ogden and Josh Levine. Motivation High level overview Walk through the common operations How not to break things (too badly)](https://reader031.vdocuments.net/reader031/viewer/2022032708/56649e725503460f94b71b71/html5/thumbnails/23.jpg)
What is the current state of the repository?◦ git status
What has changed since last commit?◦ git diff
What is currently in the index?◦ git diff --cached
What was the last commit?◦ git show
What are all the commits before the current?◦ git log
Graphical view of history◦ gitk
Other useful commands