Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Find out which remote a local branch is tracking



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


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

With git branch I get an indication of what is current:

$ git branch
* master

but there's no "*" in git remote output.

like image 707
Chris Nelson Avatar asked Nov 29 '22 08:11

Chris Nelson

1 Answers

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)
like image 117
beenhere4hours Avatar answered Feb 03 '23 20:02