Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between 'git branch -r' and 'git remote show origin'

Tags:

git

git-remote

I've seen this answer (git branch -r vs git remote show origin) which notes that one queries locally whilst the other connects to the server. However, the displayed format for these queries is different.

Is there a difference in what they display or do they simply show the same information but formatted very differently?

like image 627
Snowcrash Avatar asked Oct 16 '25 04:10

Snowcrash


1 Answers

You can see exactly what's fetched from the remote server by comparing the output of git remote show origin with git remote show -n origin. The latter command will not connect to the remote server. As a result, it does not query which branch the server's HEAD is on, and uses locally cached information in a few places.

git branch -r shows information on which branches your local tracking branches push to. git remote show origin shows that, plus more information: which branch is checked out on the server, the URLs your remote uses, and how your git configuration is set up to treat a push.

like image 131
Borealid Avatar answered Oct 17 '25 17:10

Borealid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!