1

Ok the situation is as follows: I have a git branch in my local repository called 'feature-branch'.
This branch is git-svn enabled, it is tracking the local branch 'remotes/svn/branches/feature-branch' .
And this branch is tracking a SVN branch in an external repository.

Now I know how to determine which SVN branch is tracked, this can be done with git svn info . However, how can I determine which LOCAL remote branch is tracked by my feature branch? Ie. how can I determine 'feature-branch' is tracking 'remotes/svn/branches/feature-branch' ?

With 'normal' tracking branches in GIT, I can do git branch -avv and it will show for each branch with branch it is tracking. (Which is also pretty cumbersome...)

My end goal is to be able to show the commits which have not yet been pushed to the SVN repository. I can do this easily by running git log $remote..HEAD . But then I need to know what $remote is ...

1 Answers1

1

Your feature-branch is tracking a git commit (defined by an SHA1 hash). It is not tracking an SVN branch as git-svn does not create a remote for the SVN server (all fetch/rebase/tag/branch/commit functions to/from the SVN server are done using git svn ...).

Per the git-svn documentation:

note the following rule: git svn dcommit

will attempt to commit on top of the SVN commit named in

git log --grep=^git-svn-id: --first-parent -1

...so you were correct in using git svn info or git log --grep=^git-svn-id: --first-parent -1 to determine the SVN tracked branch.


To find out all of the other known Git branches which contain a certain commit (based on SHA1 hash) try git branch --all --contains <commit-hash> (ex: git branch --all --contains 856ce -- partial hashes should work fine).

To get the full commit hash of your current branch try git rev-parse HEAD. However, you will likely want the full commit hash of the last SVN commit instead, so you will want to use the SHA1 hash of the output from git log --grep=^git-svn-id: --first-parent -1.


To get the log from the last commit to HEAD, you need to find your SVN tracking branch (as you have already figured out how to do) and plug it into the following:

git rev-list --date-order --max-count=1 <svn-tracked-branch>
git log <above-returned-hash>..HEAD

ex (with git, partial hashes almost always work):

$ git rev-list --date-order --max-count=1 trunk
117bbf6390a6cd62b47e9335be6a6d93c99d88e7
$ git log 117bbf..HEAD
commit f071e1781a98c33c2b36c21aedce4a9ab2311d47
Author: Me <me@myemail.com>
Date:   Fri Aug 30 15:19:27 2013 -0700

    test

You will probably get more useful information if you use the SHA1 hash from git log --grep=^git-svn-id: --first-parent -1 rather than taking the extra step of running the git rev-list --date-order --max-count=1 <svn-branch> command.

Shadow Man
  • 3,234
  • 1
  • 24
  • 35