我尝试过gitbranch-r,但它只列出了我在本地跟踪的远程分支。我如何找到我没有的列表?(该命令是否列出所有远程分支或仅列出未跟踪的分支对我来说无关紧要。)
当前回答
对于这里的绝大多数访问者来说,“我如何在Git 1.7+中列出所有远程分支?”这个问题的正确和最简单的答案是:
git branch -r
对于少数[1]git分支-r不起作用。如果gitbranch-r不起作用,请尝试:
git ls-remote --heads <remote-name>
如果git branch-r不起作用,那么可能正如Cascabel所说的“您修改了默认的refspec,这样git fetch和git remote update就不会获取所有远程的分支”。
[1] 在撰写本脚注2018年2月时,我查看了评论,发现git branch-r适用于绝大多数人(约90%或140人中的125人)。
如果gitbranch-r不起作用,请检查git-config-get-remote.origin.fetch是否包含通配符(*)
其他回答
试试这个。。。
git fetch origin
git branch -a
remoteshow显示远程上的所有分支,包括那些本地未跟踪的分支,甚至那些尚未提取的分支。
git remote show <remote-name>
它还尝试显示分支相对于本地存储库的状态:
> git remote show origin
* remote origin
Fetch URL: C:/git/.\remote_repo.git
Push URL: C:/git/.\remote_repo.git
HEAD branch: master
Remote branches:
branch_that_is_not_even_fetched new (next fetch will store in remotes/origin)
branch_that_is_not_tracked tracked
branch_that_is_tracked tracked
master tracked
Local branches configured for 'git pull':
branch_that_is_tracked merges with remote branch_that_is_tracked
master merges with remote master
Local refs configured for 'git push':
branch_that_is_tracked pushes to branch_that_is_tracked (fast-forwardable)
master pushes to master (up to date)
使用GitBash,您可以使用:
git branch -a
确保列出的远程源确实是所需的存储库,而不是较旧的克隆。
git branch -a | grep remotes/*
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- 在GitHub上有一个公共回购的私人分支?
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式