我在一个分支上做了一些更新并将其 merge 到主分支。 但似乎我犯了一个错误,而且我不知道如何修复它。
git log --all --decorate --oneline --graph
给出这个:
* 85b7966 (HEAD -> master, origin/master, origin/HEAD) Merge pull request #2 from doom-fr/improve-documentation
|\
| * 547f135 (origin/improve-documentation) Improve documentation : add linux installation instructions
|/
* 66dac19 Merge pull request #1
我认为 (origin/improve-documentation)
不应该在那里。
如何删除它?
最佳答案
您所描述的以及 git log 命令显示的内容非常有意义。
origin/improve-documentation
标记上次使用 git 命令连接到远程存储库时,改进文档分支所指向的位置。
如果你想让它消失,你需要确保两件事:
improve-documentation
必须在 GitHub 上删除分支(或者您正在使用的其他远程存储库)- 再次更新本地主分支时,请使用
git pull --prune
告诉 git 丢弃所有指向不再存在的远程分支的本地指针(默认情况下不这样做)。
如 Automatic prune with Git fetch or pull 中所述您还可以通过以下方式在本地为您的特定 Remote 修剪默认行为
git config remote.origin.prune true
或全局用于您使用的每个 git 存储库
git config --global fetch.prune true
关于Git 删除 git 日志中的原点/分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65309178/