1

I have merged a feature branch back onto develop, but it keeps re-appearing when I do a 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)

Notice the "forced update" , this command adds 14 commits to the branch.

The merge is subsequently deleted and the feature branch in quesiton restored as if I had not merged it.

Stephane Gosselin
  • 9,030
  • 5
  • 42
  • 65

2 Answers2

2

git fetch gets commits—and branch names—from some other Git. It then renames their branch names, such as feature, to your remote-tracking names such as origin/feature.

If you delete your own origin/feature remote-tracking name, that has no effect on the other Git. Running git fetch origin will find that origin has a branch named feature, and will therefore update-or-create your own 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.

To do that, see How do I delete a Git branch both locally and remotely?

torek
  • 448,244
  • 59
  • 642
  • 775
1

You probably still have the branch on the remote server. Run push to delete it:

git push origin :name_of_the_branch
knittl
  • 246,190
  • 53
  • 318
  • 364