The best command to run is git remote show [remote]
. This will show all branches, remote and local, tracked and untracked.
Here's an example from an open source project:
> git remote show origin
* remote origin
Fetch URL: https://github.com/OneBusAway/onebusaway-android
Push URL: https://github.com/OneBusAway/onebusaway-android
HEAD branch: master
Remote branches:
amazon-rc2 new (next fetch will store in remotes/origin)
amazon-rc3 new (next fetch will store in remotes/origin)
arrivalStyleBDefault new (next fetch will store in remotes/origin)
develop tracked
master tracked
refs/remotes/origin/branding stale (use 'git remote prune' to remove)
Local branches configured for 'git pull':
develop merges with remote develop
master merges with remote master
Local refs configured for 'git push':
develop pushes to develop (local out of date)
master pushes to master (up to date)
If we just want to get the remote branches, we can use grep
. The command we'd want to use would be:
grep "\w*\s*(new|tracked)" -E
With this command:
> git remote show origin | grep "\w*\s*(new|tracked)" -E
amazon-rc2 new (next fetch will store in remotes/origin)
amazon-rc3 new (next fetch will store in remotes/origin)
arrivalStyleBDefault new (next fetch will store in remotes/origin)
develop tracked
master tracked
You can also create an alias for this:
git config --global alias.branches "!git remote show origin | grep \w*\s*(new|tracked) -E"
Then you can just run git branches
.