Branches, merging and rebasing: more git

Andrew Straw

13 July 2012

Background refresher

Recall how git stores its history as a series of commits.

Image from

Local operations

Image from

File status lifecycle

Image from

Branches, merging, pushing

“gitk –all” shows all branches in repository


Tasklist for today:

  1. 1)Fork a repository into your github account. 

  2. 2)Clone this repository from your github account onto your local machine. 

  3. 3)Make a new branch called “development” (or whatever descriptive title you want) 

  4. 4)Add some commits to this branch 

  5. 5)Push these commits (in the new “development” branch) back to your github repository 

  6. 6)Issue a pull request against the original repository. 

(Members of my lab: repeat as necessary when updating our software.)


Fork a repository into your github account.


Clone from your github account to your local machine

Change into a comfortable directory and then:

git clone

Make a new branch

Now, do this:

cd py4science-vbc/

git branch development

git checkout development

Add some commits to this branch

# edit your files

git add filename1

git commit -m "commit message"

Push these commits back to your github account

git push origin development

Now issue a pull request


Now, people with permissions on the original github repository can accept/reject your pull request, ask for changes or make other comments all through the github website.