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

San*_*Kim 7 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.
Run Code Online (Sandbox Code Playgroud)

我也尝试过,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
Run Code Online (Sandbox Code Playgroud)

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

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

> git branch 
* master                   # I think it should show barnch A also
Run Code Online (Sandbox Code Playgroud)

noa*_*hnu 11

git branch仅显示本地分支. git branch -r将显示远程分支,正如您自己所见.

git branch
*master

git branch -r
origin/master
origin/A
Run Code Online (Sandbox Code Playgroud)

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

你想要做的是检查分支机构.这将生成远程分支的本地副本,并将上游设置为远程分支.

git checkout -b mylocal origin/A

git branch
master
*mylocal

git branch -r
origin/master
origin/A
Run Code Online (Sandbox Code Playgroud)

mylocal在这种情况下是origin/A.该-b参数将在创建后切换到新分支.您也可以输入:git checkout A将自动命名新分支.