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.
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
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 -amight give you the information you want. Alternatively you can do something likegit rev-list origin/master..mylocal | wc -lto get a count of how many commits away fromorigin/masteryou are, and do this with all the remote branches until you find the smallest distance.