You are on page 1of 22

Remote repos process

(single committer)
Public Repo
Located on
Server (Github)

git push

Private Repo
Located on your
local machine

git commit -m ‘…’ git add filename vi filename

Commit Changes Stage Changes Make file changes


Remote repos process
(multiple committers)
Public Repo
Located on
Server (Github)

2) git pull

1) git push

Bob’s Private Repo


Located on Bob’s local
Private Repo machine
Located on your
local machine

git commit -m ‘…’ git add filename vi filename

Commit Changes Stage Changes Make file changes


Remote repos process
(multiple committers)
Public Repo
Located on
Server (Github)

1) git push

2) git pull

Bob’s Private Repo


Private Repo Located on Bob’s local
Located on your machine
local machine
git commit -m ‘…’ git add filename vi filename

Commit Changes Stage Changes Make file changes


Public/Private Repo Setup
Project Public Repo Your Public Repo Other Public Repos

Jasonnoble/ Fork your-user-name/ hosh/


event_scheduler event_scheduler event_scheduler
(on GitHub) (on GitHub) (on GitHub)

stonean/
event_scheduler
(on GitHub)
Clone

event_scheduler
Public Repo
Local Repo
Private Repo
Open source project
on GitHub
•  http://github.com/jasonnoble/event_scheduler
–  Click Fork
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
Your project on GitHub
•  http://github.com/your-user-name/event_scheduler
Clone your Repo
•  git clone 

git@github.com: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
Pushing/Pulling to upstream
Other forks

Jasonnoble/ your-user-name/ hosh/


event_scheduler event_scheduler event_scheduler

upstream origin hosh

git push upstream master

event_scheduler
git pull upstream master Local Repo

Allowed by default Remotes:


origin
Requires permission upstream
hosh
Add upstream
•  In order to pull updates from other sources, you need
to add a remote server
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
Create local branch
•  git checkout --track -b upstream-master
upstream/master
–  upstream-master is what you will call it locally
Pull remote changes
•  git checkout upstream-master
•  git pull
–  pull updates from the remote
Show diffs between branches
•  git show-branch
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
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
Modify a file
•  vi (or your favorite editor) AUTHORS
•  Add your name
•  Save the file
•  Commit the change
Pushing/Pulling to Origin
Other forks

Jasonnoble/ your-user-name/ hosh/


event_scheduler event_scheduler event_scheduler

origin

git push git pull

event_scheduler
Local Repo

Allowed by default Remotes:


origin
Requires permission upstream
hosh
Git Push
•  Push your changes to GitHub
•  git push origin master
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
Pull Requests (cont.)

You might also like