This is not Find out which remote branch a local branch is tracking, If I have mulitple remotes, I might have "master" in all of them. git branch
returns master but I don't know if the master branch I'm on is in remoteFoo or remoteBar. For example, I might do:
git clone someRepo.git
cd someRepo
git remote add anotherRemote otherremoteURL
Then git remote
shows
someRepo
anotherRemote
I can do git checkout -b master someRepo/master
or git checkout -b master anotherRemote/master
and git branch
will say "master" in both cases. How do I get back the first part, "someRepo" or "anotherRemote"?
You'd think I could use git remote show
but it requires an argument, the name of the remote you want information on.
$ git remote show origin
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
$ git remote show
someRepo
anotherRemote
With git branch
I get an indication of what is current:
$ git branch
hold
* master
old-stuff
refactor
but there's no "*" in git remote
output.
You may want to try these below to view in detail the information.
git remote -v
git remote -v show origin
Example output below:
dmasi@:/var/www/pirate_booty$ git remote -v
origin [email protected]:dmasi/pirate_booty_calculator.git (fetch)
origin [email protected]:dmasi/pirate_booty_calculator.git (push)
dmasi@:/var/www/pirate_booty$ git remote -v show origin
* remote origin
Fetch URL: [email protected]:dmasi/pirate_booty_calculator.git
Push URL: [email protected]:dmasi/pirate_booty_calculator.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With