git atlrug
DESCRIPTION
Intro to Git slide deck give as a presentation to the Atlanta Ruby Users Group.Covers Forking, pushing and pulling to Github, Pull requestsTRANSCRIPT
![Page 1: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/1.jpg)
![Page 2: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/2.jpg)
Remote repos process(single committer)
Public RepoLocated on Server (Github)
Private RepoLocated on your local machine
git push
Make file changesStage ChangesCommit Changes
git add filenamegit commit -m ‘…’ vi filename
![Page 3: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/3.jpg)
Remote repos process(multiple committers)
Public RepoLocated on Server (Github)
Private RepoLocated on your local machine
1) git push
Make file changesStage ChangesCommit Changes
git add filenamegit commit -m ‘…’ vi filename
Bob’s Private RepoLocated on Bob’s local machine
2) git pull
![Page 4: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/4.jpg)
Remote repos process(multiple committers)
Public RepoLocated on Server (Github)
Private RepoLocated on your local machine
2) git pull
Bob’s Private RepoLocated on Bob’s local machine
Make file changesStage ChangesCommit Changes
git add filenamegit commit -m ‘…’ vi filename
1) git push
![Page 5: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/5.jpg)
Public/Private Repo SetupJasonnoble/event_scheduler(on GitHub)
your-user-name/event_scheduler(on GitHub)
hosh/event_scheduler(on GitHub)
Fork
Other Public Repos
event_scheduler Local Repo
Clone
Your Public RepoProject Public Repo
stonean/event_scheduler(on GitHub)
Public Repo
Private Repo
![Page 6: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/6.jpg)
Open source project on GitHub
• http://github.com/jasonnoble/event_scheduler– Click Fork
![Page 7: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/7.jpg)
Fork Command
• Fork is a GitHub thing, it’s not a Git command• Clicking fork basically copies a repo on Github into your Github account• This provides a public repo that you have access to push your changes to
![Page 8: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/8.jpg)
Your project on GitHub• http://github.com/your-user-name/event_scheduler
![Page 9: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/9.jpg)
Clone your Repo• git clone
[email protected]:your-user-name/event_scheduler.git• cd event_scheduler• git pull
– Should say “Already up-to-date”
• This clone command adds a remote repo “origin” (explained in detail later)
• A clone is the entire history of the Git Repo– History of all changes– Log messages
![Page 10: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/10.jpg)
Pushing/Pulling to upstreamJasonnoble/event_scheduler
your-user-name/event_scheduler
hosh/event_scheduler
Other forks
event_scheduler Local Repo
upstream origin hosh
Allowed by default
Requires permission
git push upstream master
git pull upstream master
Remotes: origin upstream hosh
![Page 11: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/11.jpg)
Add upstream• In order to pull updates from other sources, you need
to add a remote server
![Page 12: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/12.jpg)
Add upstream (cont.)
• git remote add upstream git://github.com/jasonnoble/event_scheduler.git
– “upstream” is whatever you want to call it– “upstream” for the repo you forked from is a
GitHub convention• git fetch upstream
– Fetches references from upstream
![Page 13: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/13.jpg)
Create local branch
• git checkout --track -b upstream-masterupstream/master– upstream-master is what you will call it locally
![Page 14: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/14.jpg)
Pull remote changes
• git checkout upstream-master• git pull
– pull updates from the remote
![Page 15: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/15.jpg)
Show diffs between branches
• git show-branch
![Page 16: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/16.jpg)
Merge branches
• git checkout master• git merge upstream-master
– Merges any changes committed to upstream-master into the master branch
• After merge, do a git push to push that merge to your public repo on GitHub
![Page 17: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/17.jpg)
Pulling from Upstream Lab
• I will commit a change to my public repo (upstream)
• You add upstream as a remote repo• Pull from the repo to get the changes
![Page 18: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/18.jpg)
Modify a file
• vi (or your favorite editor) AUTHORS
• Add your name
• Save the file
• Commit the change
![Page 19: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/19.jpg)
Pushing/Pulling to OriginJasonnoble/event_scheduler
your-user-name/event_scheduler
hosh/event_scheduler
Other forks
event_scheduler Local Repo
git pull
origin
git push
Allowed by default
Requires permission
Remotes: origin upstream hosh
![Page 20: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/20.jpg)
Git Push
• Push your changes to GitHub• git push origin master
![Page 21: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/21.jpg)
Pull Requests
• After you push new code to your forked repo, you can request others pull your requests
• http://github.com/your-user-name/event_scheduler• Click Pull Request• Enter a quick message about what you changed• Enter receipients
– All users who have forked upstream are listed– Check users as requested
![Page 22: Git Atlrug](https://reader036.vdocument.in/reader036/viewer/2022062312/554a5689b4c9054b328b4bb1/html5/thumbnails/22.jpg)
Pull Requests (cont.)