[kwlug-disc] Advanced(?) Git usage question
Chris Frey
cdfrey at foursquare.net
Tue Apr 15 21:44:20 EDT 2014
On Tue, Apr 15, 2014 at 08:47:41PM -0400, John Johnson wrote:
> A tip on Git that I read somewhere was to develop a consistent style
> in the git commit messages, e.g. git -am [message text], so as to
> make subsequent searches easier. For example, if one was using an
> issue tracking system with issues SCR 1024 SCR 2031 SCR 112 being
> active and the commit was to combine repairs that addressed these
> issues, the commit message could be: git commit -am "issues: SCR
> 1024 SCR 2031 SCR 112" or similar.
That "git commit -am" worries me. :-) My usual process is:
git add -p
git commit # with editor
This allows more detailed commit messages than just a single line.
And the git-add with '-p' makes sure you only commit the changes you
intend. You can also break your current workspace into multiple
commits, making them small and logical.
Also, in git, the first line is special, as you probably know.
But there exists a --grep option in commands such as git-log, for
searching commit messages. For example, if your commit message said:
driver: fixed off-by-one error in buffer init
Changed code to use sizeof() instead of hard coded value.
Fixes SCR 1024, SCR 2031, SCR 112
Now, if you do:
git shortlog
you get a nice brief description of your changes, yet you still have
your bug tracking IDs in the commits, so that this is possible:
git log --grep="SCR 2031"
- Chris
More information about the kwlug-disc
mailing list