git - 如何获取所有远程分支, "git fetch --all"不起作用

标签 git version-control fetch

我已经浏览过关于类似问题的其他问题。

但他们似乎说答案是git fetch --all

但就我而言,它不起作用。

这就是我为此所做的。

> git branch
* master

> git branch -r
origin/master
origin/A

> git fetch --all
> git branch 
* master        #still not updated

> git fetch origin/A
fatal: 'origin/A' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

> git fetch remotes/origin/A
fatal: 'origin/A' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我也尝试了 git pull --all 但结果是一样的。

----------------编辑--------------------

> git pull --all
Already up-to-date.

> git branch 
* master              # I think it should show branch A also

> git remote show origin
 HEAD branch: master
 Remote branches:
   A      tracked
   master tracked

----------------编辑--------------------

> git pull origin A
 * branch            A       -> FETCH_HEAD
Already up-to-date.

> git branch 
* master                   # I think it should show barnch A also

最佳答案

git branch 只显示本地分支。 git branch -r 将显示远程分支,如您所见。

git branch
*master

git branch -r
origin/master
origin/A

git fetch --all 将更新您在键入 git branch -r 时看到的列表,但它不会创建相应的本地分支。

您要做的是检查分支机构。这将制作远程分支的本地副本并将上游设置为远程。

git checkout -b mylocal origin/A

git branch
master
*mylocal

git branch -r
origin/master
origin/A

mylocal 在这种情况下是 origin/A。如果分支不存在,-b 参数将创建分支。您也可以只键入:git checkout A 将自动命名新分支。

关于git - 如何获取所有远程分支, "git fetch --all"不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31445129/

相关文章:

sql - 为什么 FETCH FIRST N ROWS 不能与 WITH 语句结合使用?

javascript - 即使 promise 为 200,也无法从刷新 token 生成新的访问 token

performance - Git 在 Big Commits 与 tiny commits 方面的表现

c++ - 查找项目中未使用的文件

javascript - 关闭模式后刷新使用自定义 Hook 获取的数据

svn - Subversion 与 CVS

Git + 大数据集?

git - .gitignore 文件忽略所有文件但不忽略嵌套文件

eclipse - 我可以有一个既是 git 工作区又是 svn 工作区的工作区吗?

Git 跟踪上游