Reputation: 3865
I used this command to check out a local branch 'mylocal' from remote branch 'origin/mater'.
git checkout -b mylocal origin/master
But, after awhile I forgot from which remote branch I created my local branch 'mylocal'.
Is there any git command that I can use to show the corresponding remote branch for my local branch?
Thanks.
Upvotes: 4
Views: 220
Reputation: 185653
If you have upstream information set up for your branch (which git may or may not have done automatically, depending on configuration) then you can use
git rev-parse --symbolic-full-name --abbrev-ref mylocal@{u}
This should output the remote branch that it was created from. If such information does not exist, then you're just going to have to compare your branch with the remote branches to see which diverges the most. git show-branch -a
might give you the information you want. Alternatively you can do something like git rev-list origin/master..mylocal | wc -l
to get a count of how many commits away from origin/master
you are, and do this with all the remote branches until you find the smallest distance.
Upvotes: 2