Skip to content

Bulk ammending commit messages in git

At my job I’m using git-p4 to work locally with some rails code in git and push to perforce. It’s working okay but one issue for me is that we require every commit to perforce to have a code review by someone, and we put the reviewer’s name at the bottom of each commit. For example:

Live changes to histograms
-commonized the histograms views & logic

CR: JamesM

Well when I’m working in the git repo, I don’t know who is going to code review it, so I end up having to add CR: JamesM to several commits. It can be done with rebase -i, but it is several steps per commit. I could use git-notes, but that doesn’t follow the format that we like (it puts Notes: in). Because this is a local repo only, changing the commit history is not a big deal. After some searching I found the way:

git filter-branch --msg-filter 'cat && echo "CR: REVIEWER"' p4/master~1..HEAD

This little beauty will append CR: REVIEWER to all of the commits from the master to the current head (all of the local commits).

One Comment

  1. Rob wrote:

    Mike,

    I found your website via the STL Mobile Dev group and its meeting descriptions page. https://groups.google.com/forum/#!forum/stl-mobile-dev and http://sites.google.com/site/stlmobiledev/meetings/meeting-1 In January 2010 you took part in a Mobile Dev meeting and talked about the Palm Pre. At least, I assume that’s what you did. I wasn’t there, I’m just reading the meeting’s notes. Anyway, I was wondering if you’re still involved with webOS at all. If so, I’d like to invite you to a webOS Social held at The Tap Room on August 20. It’s the first webOS meeting in STL and I’m the ringleader. If you’d like more information please see our Meetup.com page: http://www.meetup.com/HPwebOS/Saint-Louis-MO/

    Or just email me.

    If you’ve been long-gone from webOS, I’m sorry to have bothered you. But if you’re still involved in webOS I think you’d have a nice time. In less than two months from now there will be a formal HP webOS Developer’s Meeting in STL, in case you’re interested.

    Cordially,

    Rob

    Thursday, August 11, 2011 at 5:42 pm | Permalink

Post a Comment

Your email is never published nor shared.