Skip to content

Instantly share code, notes, and snippets.

@mocoso
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mocoso/3e4c4233c7041585b0ef to your computer and use it in GitHub Desktop.
Save mocoso/3e4c4233c7041585b0ef to your computer and use it in GitHub Desktop.
Improve your git notes

Notes from "Improve your git"

Joel Chippindale / CTO, FutureLearn / @joelchippindale

A tutorial from BarCamp London X

We talked about using git commits to tell a story about your code and two things that helped

  1. Commit messages

    Use your commits to explain the intent of your changes not just what you have done, see Deliberate Git and Every line of code is always documented on how and why to do this.

    Avoid unrelated changes in the same commit. It's easier to merge commits than split them apart so err on the side of small commits in development.

    Also Tim Pope's notes on git commit style are good.

  2. Keeping a simple history

    When committing to master we first rebase the branch on master and for sets of commits that belong together where we use merge --no-ff to indicate that they are part of the same set of changes, see Mislav's post for more detail.

Exercises with git rebase --interactive

The githug gem provides a set of interactive exercises with git with a few which cover git rebase --interactive

$ gem install githug

$ githug play

Then use reset to pick the exercises that make use of git rebase —interactive when you have finished each exercise type githug play to check you have finished.

$ githug reset rename_commit

$ githug reset squash

$ githug reset merge_squash

$ githug reset reorder

Other stuff we mentioned

  • git blame for finding out which commit a line was last changed in
  • git log --oneline --abbrev-commit --all --graph --decorate for a nice command line view of the commit tree for your repo
  • git reflog for getting back to where you've been
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment