I’ve been using Git+SVN for a while now, and I really like what it does for me. What I don’t like is the constant repetition of the same command to update from svn into my local git branch, over and over and over again. So, I wrote a little batch file to do my svn update and my git commit. I committed it to our repository so that I wouldn’t lose it when branching, merging, etc. and one of my coworkers asked if it was populating any useful info into the git commit message, like the svn revision #. At the time it was only committing with a “svn up” message, but it was easy to add other detail.
Since I run in a bash shell most of the time (the Git Bash shell… MingW32), I decided to take advantage of the bash commands like grep and piping, etc, to get the svn info that I wanted into my commit message. I wanted to get the svn revision number. This can be obtained by running “svn info”:
the “Revision: 30165” line is what I’m looking, so a simple command like “svn info | grep Revision” should do the trick:
Then, with a little help from Tim Ottinger, I got the command line i needed to insert this info into my git commit message: git commit –m “$(svn info | grep “Revision”*)”
The resulting batch file has these commands in it:
1: svn up
2: git add -A
3: git commit -m "svn up to $(svn info | grep "Revision"*)"
And it looks like this when I run it, proving a nice log entry for me:
Post Footer automatically generated by Add Post Footer Plugin for wordpress.