I recently had the pleasure of collaborating with another developer on a project. Both of us are used to working alone and as such we had to make sure we had some processes in place to keep us both on the same page. Being somewhat more comfortable with Git than was my collaborator, I took the lead on source control. What follows is a quick and dirty cheat sheet I wrote for the basics of a Git + GitHub workflow.

New Branch

To be created whenever building a new feature, or addressing a new issue. Try to name after feature or issue

git checkout master
git pull
git checkout -b new-branch-name
git push -u origin new-branch-name`

Commit Changes

Do frequently, whenever one piece of a feature is complete or whenever you need to step away from the computer. The smaller the commit, the easier it is to retrace your steps. Best to push after every commit, in case your computer suddenly gets hit by a meteor. git add . git commit -m "Describe briefly what this commit does" git push

Merge Branch

This is done in GitHub.

  • Browse to branch
  • New Pull Request
  • Submit Pull Request
  • Deal with conflicts (or ask Dave to)
  • Submit merge.
  • Delete branch
  • Go back to the steps for new branch (checking out master and pulling is crucial here.)

Other handy commands

git status

Feel free to check the status every other command. It's a great security blanket.

git stash

Do this to temporarily get rid of all changes since last commit.

git stash apply

Do this to re-apply those changes. Note that you can git checkout branch-name or do other things in between a stash and a stash apply. Handy when you started working on the wrong branch.

git stash clear

Best to do if you aren't planning on applying. Otherwise those changes could just sit there and come back when you try to stash apply something else later.