How to determine LOCAL tracked branch?
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’ ?
- Changing working folder location
- Never-ending GIT story - what am I doing wrong here?
- Import files directly to SVN repo without checking out first
- What is the svn:mergeinfo equivalent for git?
- Delete file from the working copy only but not from the repository
- In Eclipse, how can I exclude some files (maybe based on the .svn extension or filename) from being copied to the output folder?
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 …
One Solution collect form web for “How to determine LOCAL tracked branch?”
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 <firstname.lastname@example.org> 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.