MarkUs Blog

MarkUs Developers Blog About Their Project

How to use git with MarkUs

without comments

Here’s a simple rundown of some commands Tobi and I came up with in preparation for the sprint. You can use these to contribute to MarkUs. This post assumes you have already set up a github account and an ssh public key that you will be using later on.

Setting up MarkUs

  • Visit the upstream repo on github and select “Fork”. This will create a clone of the repository on your github account.
  • From your fork, copy the URL that allows you to access it using SSH.
  • Run the following command in terminal using the URL you just copied.
    $ git clone
  • Next, create a remote to the master repository of MarkUs upstream. This will be used to keep your local copy up to date.
    $ git remote add markus-upstream git://
  • Make sure the remote was added.
    $ git remote -v
    You should see “markus-upstream” and “origin”.
    Note the remote origin, it should point to the SSH URL you cloned with. If this URL contains “https”, then you have not cloned using SSH. Run the following command to change it to the URL used when cloning (see above).
    $ git remote set-url origin

Simple Development

From the MarkUs root directory in a terminal, run the following commands:

  • Create a branch
    $ git branch issue-1234
    $ git checkout issue-1234
  • Modify the files with the changes you want to implement. Let’s say I’ve modified Changelog and with the most amazing fix for issue 1234!
  • Take a look at the files you have modified
    $ git status
  • Then commit these changes
    $ git add Changelog
    $ git commit -m "FIX for issue 1234, implemented awesome function."
  • Before setting up a review request, make sure your issue and master branches are up to date (see below), making sure the changesets you just pulled in do not affect your code. Once they are, setup a review request.
    $ git push origin issue-1234
    Go to your github fork and change to your issue branch. You should see the button “Pull Request” (right by the button to fork). In the write fill, fill it in with the issue number, quick summary of the issue, desciption of the fix and what testing was performed.

Keeping your local clone up to date

  • First, make sure you have already set up your upstream remote. Note, mine is called "markus-upstream". Substitute your remote name whenever you see this. Run the following commands from terminal.
  • To update your local master branch $ git checkout master $ git pull markus-upstream master
  • To integrate these changes into your current issue branch $ git checkout issue-1234 $ git merge/rebase master

Some useful commands

  • Setup your git configuration settings. $ git config --global "First-name Last-name" $ git config --global ""
  • View what changes you have made on branch "issue-1234"
    $ git diff --full-index master issue-1234
  • Temporarily put  your changes aside to have a cleanly tracked branch $ git stash Bring these changes back (even onto another branch, as long as it is within the same repository) $ git stash pop
  • Remove all changes made to a specific file. Let's say I no longer want the changes I've made to app/models/membership.rb $ git checkout app/models/membership.rb
  • Revert all changes made to the current branch (WARNING: All changes will be lost). $ git reset --hard HEAD
  • Once your branch, issue1234, has been integrated into master, you might want to delete it. $ git branch -d issue1234 $ git push origin :issue1234
  • You might want to see who added/modified a line last, and what other changes they brought in with that changeset. $ git blame config/routes.rb This might be easier to do directly on github though! Here's an example.

Written by Danesh

January 28th, 2012 at 7:14 pm

Posted in Uncategorized

Leave a Reply