loading...

How to plan an impactful git log

kwstannard profile image Kelly Stannard ・1 min read

You have decided that you would rather have your git log be concise and informative than a minute-by-minute log of everything you did. But your commit log still doesn't feel as useful as it should be. Some changes seem random or unrelated to the commit message it was introduced in. Squashing everything is a chore.

Git provides you with some features for creating great messages that will even tie into a gitlab feature.

Step zero

Setup your gitconfig with the following.

[alias]
  fu = commit -a --fixup
  fuh = commit -a --fixup HEAD
  sq = commit -a --squash
  sqh = commit -a --squash HEAD
  squash = "!f() { git rebase -i --autosquash ${1:-master}; }; f"

Starting your work

Do some work and commit it with a message describing what the feature is.

When you make a decision or major change

Run git sqh and provide a message explaining your decision or change.

When you need to push or make some trivial changes

Run git fuh to commit without a message.

When you are done with the feature

Run git squash to clean up the commit history. You will first be presented with the interactive rebase prompt and you probably wont need to do anything and just save and exit the prompt. Then you will be presented with a final commit message with the initial commit message and all the squash messages you made before and you can use all that information to write an informative commit message for future developers.

Appendix

For more information read the documentation at man git-commit and man git-rebase.

Posted on by:

kwstannard profile

Kelly Stannard

@kwstannard

Developer. Design pattern enthusiast. Tilting at Agile practices.

Discussion

pic
Editor guide