简体   繁体   English

无法合并/删除功能分支

[英]Cannot merge / delete feature branch

I have merged a feature branch back onto develop, but it keeps re-appearing when I do a git fetch --all --prune. 我已经将一个功能分支合并到了develop上,但是当我执行git fetch --all --prune时它会不断重新出现。

The commits from the merged branch also reappear on the merged branch, and the deleted branch is recreated. 合并分支的提交也会重新出现在合并的分支上,并重新创建已删除的分支。

What could be causing this behavior? 什么可能导致这种行为?

After merging and deleting feature branch, doing a fetch outputs the following: 合并和删除功能分支后,执行获取输出以下内容:

Fetching origin From bitbucket.org:Project/projectName + fbfe775...9ad9ec2 develop -> origin/develop (forced update) 获取来自bitbucket.org:Project/projectName + fbfe775 ... 9ad9ec2 develop - > origin / develop(强制更新)

Notice the "forced update" , this command adds 14 commits to the branch. 注意“强制更新”,此命令会向分支添加14个提交。

The merge is subsequently deleted and the feature branch in quesiton restored as if I had not merged it. 随后删除合并,并在quesiton中恢复功能分支,就好像我没有合并它一样。

git fetch gets commits—and branch names—from some other Git. git fetch其他一些Git获取提交和分支名称。 It then renames their branch names, such as feature , to your remote-tracking names such as origin/feature . 然后,它将分支名称(例如feature重命名为远程跟踪名称,例如origin/feature

If you delete your own origin/feature remote-tracking name, that has no effect on the other Git. 如果删除自己的origin/feature远程跟踪名称,则对其他 Git没有影响。 Running git fetch origin will find that origin has a branch named feature , and will therefore update-or-create your own origin/feature . 运行git fetch origin会发现origin有一个名为feature的分支,因此会更新或创建自己的origin/feature

What you must do, then, is clear: remove the branch name feature from the other Git repository , so that when your Git connects to their Git, they don't have branch name feature and your Git won't update-or-create your own origin/feature , and in fact, with --prune , will delete your origin/feature if it exists. 那么你必须做的是明确的: 从其他Git存储库中删除分支名称 feature ,这样当你的Git连接到他们的Git时,他们没有分支名称feature ,你的Git 将不会更新或创建您自己的origin/feature ,事实上,使用--prune ,将删除您的origin/feature如果存在)。

To do that, see How do I delete a Git branch both locally and remotely? 为此,请参阅如何在本地和远程删除Git分支?

You probably still have the branch on the remote server. 您可能仍然在远程服务器上有分支。 Run push to delete it: 运行push删除它:

git push origin :name_of_the_branch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM