为什么我会看到已删除的远程分支? [英] Why do I see a deleted remote branch?
问题描述
我有一个远程仓库和两个克隆。
我在其中一个克隆中创建了一个分支,例如测试
。我做了一些工作和2次提交。我将分支合并到 master
分支和 push -u
。
我做了一个 git pull
在另一个克隆中。
我看到 master
和测试
。
在我做的第一个克隆项目中:
git origin:test
删除 test
在远程仓库上分支。
test
在远程仓库上被删除。
我做了 git分支-D test
和 test
分支也在本地删除。
如果我做了 git branch -a
我得到:
* master
remotes / origin / master
现在在第二个存储库中,我执行 git pull
。
在拉本地 test
似乎被删除,但 test
分支仍然存在。
如果我做了
* master
remotes / origin / HEAD - >原产地/主人
遥控器/原产地/主人
遥控器/原产地/测试
为什么被删除的 test
分支显示为远程分支?
git fetch
(因此 git pull
)的默认选项不会删除已删除的远程分支。我不确定这个默认背后的逻辑是什么。在任何情况下,要删除已删除的远程分支,请使用
git fetch -p
或运行
git remote prune [ -n]< name>
。使用 -n
标志,它会报告哪些分支将被修剪,但并不实际修剪它们。请参阅 git-fetch(1)和< a href =https://www.kernel.org/pub/software/scm/git/docs/git-remote.html =noreferrer> git-remote(1)了解更多信息。
I have a remote repository and 2 clones.
I create a branch in one of the clones e.g. test
. I do some work and 2 commits. I merge to master
branch and push -u
the branch.
I do a git pull
in the other clone.
I see both master
and test
.
In the first clone project I do:
git origin :test
to delete test
branch on remote repository.
test
is deleted on remote repos.
I do git branch -D test
and the test
branch is deleted locally as well.
If I do git branch -a
I get:
*master
remotes/origin/master
Now in the second repository I do a git pull
.
On the pull the local test
seems to be deleted but git
seems to "think" that the remote test
branch still exist.
If I do git branch -a
I get:
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/test
Why does the deleted test
branch appear as a remote branch?
The default options for git fetch
(and consequently git pull
) do not prune deleted remote branches. I'm not sure what the logic behind this default is. In any case, to prune deleted remote branches, either fetch with
git fetch -p
or run
git remote prune [-n] <name>
explicitly. With the -n
flag, it will report which branches will be pruned, but not actually prune them. See git-fetch(1) and git-remote(1) for more information.
这篇关于为什么我会看到已删除的远程分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!