This python script is the best I have come up with so far. I just hacked it together and on a cursory first couple uses, seems to be acting correctly, but I can\'t help but
One of (they are synonyms):
git svn dcommit --dry-run
git svn dcommit -n
After playing around with Greg's suggestion, I ended up with this:
git log remotes/trunk.. --oneline
which I will either alias or wrap in a small script.
The reason why this works and his suggestion didn't is that my remopte svn branch is remotes/trunk
not git-svn
. I don't know if this is standard or not, especially since Greg assumed git-svn
.
First, do a git branch -a
to list all the remote branches:
$ git branch -a
git-svn
For me, only the git-svn
branch is listed, but you may have different names depending on what options you passed to git svn clone
. Then, use
git log git-svn..
(substituting your appropriate name for git-svn
). The above command (note the two trailing dots ..
) shows all the commits on the current branch since the nearest common ancestor of the current branch and the git-svn
branch.
I added this to my ~/.gitconfig file:
svn-status = !"git log `git svn log --show-commit --oneline --limit=1 | awk '{print $3}'`..HEAD --oneline"
which gives handy short messages if there are any changes that need dcommit, and shows nothing if you're up to date (assuming you've done a rebase or fetch). you could modify the params to the outer git-log if you like too.
Nice. Based on the info here, I use:
git config alias.svn-status \!"git log git-svn.. --oneline |wc|perl -ne 'tr/ //s;s/^ //;(\$commits)=split(/ /,\$_,2);print \"Your branch is ahead of git-svn by \$commits commits\n\"'"
This assumes the standard git-svn
default remote repo nomenclature.