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
-
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.
-
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.
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
git blame
for finding out which commit a line was last changed ingit log --oneline --abbrev-commit --all --graph --decorate
for a nice command line view of the commit tree for your repogit reflog
for getting back to where you've been