> git remote show origin* remote originFetch URL: C:/git/.\remote_repo.gitPush URL: C:/git/.\remote_repo.gitHEAD branch: masterRemote branches:branch_that_is_not_even_fetched new (next fetch will store in remotes/origin)branch_that_is_not_tracked trackedbranch_that_is_tracked trackedmaster trackedLocal branches configured for 'git pull':branch_that_is_tracked merges with remote branch_that_is_trackedmaster merges with remote masterLocal refs configured for 'git push':branch_that_is_tracked pushes to branch_that_is_tracked (fast-forwardable)master pushes to master (up to date)
运行的最佳命令是git remote show [remote]。这将显示所有分支,远程和本地,跟踪和未跟踪。
下面是一个开源项目的例子:
> git remote show origin* remote originFetch URL: https://github.com/OneBusAway/onebusaway-androidPush URL: https://github.com/OneBusAway/onebusaway-androidHEAD branch: masterRemote 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 trackedmaster trackedrefs/remotes/origin/branding stale (use 'git remote prune' to remove)Local branches configured for 'git pull':develop merges with remote developmaster merges with remote masterLocal refs configured for 'git push':develop pushes to develop (local out of date)master pushes to master (up to date)
如果我们只想获取远程分支,我们可以使用grep。我们想要使用的命令是:
grep "\w*\s*(new|tracked)" -E
使用此命令:
> git remote show origin | grep "\w*\s*(new|tracked)" -Eamazon-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 trackedmaster tracked