Git Cheatsheet

(This was intended to teach Spring 2015 CS 61B students how to submit assignments through git.)

Easy submission

Before you start an assignment, pull the skeleton code:

$ git pull skeleton master

Do all your work on the master branch. When you're done:

$ git commit -am "Message"              # Add all changes, then commit
$ git push origin master                # Push your commits to the master branch of your GitHub repo
$ git push origin master:ag/lab1        # Push to the autograder branch -- expect an email
$ git push origin master:submit/lab1    # Push to the submit branch -- no email

And that's it!

Pro tips

  • Tired of entering your username/password so often?
$ git config --global credential.helper store
  • Want to pull/change branches/merge but have work in progress?
$ git add --all :/       # Adds all changes
$ git stash              # Saves your work, then undos it
$ git stash apply        # Redos the saved work
comments powered by Disqus