Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Feature branches in remote not getting deleted

I'm having an issue with using git-flow. Not sure if this is the expected behavior so please clarify it for me.

I create an empty repo in Bitbucket and clone it to my local machine. Then I create an Xcode project (I do iOS development) inside that repo, commit it and push it to Bitbucket.

Then I went ahead and initialized my local repo to use git flow. I use SourceTree by the way. Then I created a new feature branch, let's call it FirstFeature. I add some files to the project and push it again. Now I have 3 branches in my remote repo: master, develop, and FirstFeature.

Then I work on the project again and finish off that feature. The FirstFeature branch gets deleted and merged it with develop locally. Then I proceed to push it to Bitbucket. I thought since the local branch of FirstFeature got deleted, it would get removed when I push the new changes, but apparently not. That FirstFeature branch is still there in my Bitbucket repo.

Is this expected behavior or do I need to do something extra to get these removed?

Thank you.

like image 834
Isuru Avatar asked Feb 12 '23 13:02

Isuru


2 Answers

This is expected behavior. Git does not treat the remote repository as a slave to yours; all are equal. So not all changes in your repo are immediately reflected in a remote.

You can do what you want with the following form of the git-push command:

git push origin :FirstFeature

This is a special case of the more general syntax

git push {remote-name} {local-branch}:{remote-branch}

Think of it as pushing "nothing" to the remote branch.

Equivalently, you can use

git push origin --delete FirstFeature
like image 149
George Hilliard Avatar answered Feb 14 '23 10:02

George Hilliard


You need to delete the remote topic branch as follows:

git push origin :topic_branch
like image 22
Robert Bain Avatar answered Feb 14 '23 10:02

Robert Bain