Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Git flow deletes branch on remote server?

Tags:

git

git-flow

I am using git along with git flow. Here git flow has a develop branch. Whenever i need to start feature i type

git flow feature start new 

a new branch feature/new is created. Then i do the changes and commit them using

git push origin feature/new 

After comitting the changes I finish feature using

git flow feature finish new 

it deletes feature/new branch locally. Now I am switched to develop branch by git flow and I again type

git push origin develop 

which make changes to remote server develop branch

If I type git branch -a, the new branch got deleted from the local but it is there on the server with name remotes/origin/feature/new

Does git flow delete branches on remote server which are deleted at my local machine?

Please tell me if I am making some mistake.

like image 874
Paritosh Singh Avatar asked Jun 22 '12 07:06

Paritosh Singh


People also ask

Does git branch delete from remote?

To delete a remote branch, you can't use the git branch command. Instead, use the git push command with --delete flag, followed by the name of the branch you want to delete.

Does deleting local branch delete remote branch?

In Git, local and remote branches are separate objects. Deleting a local branch doesn't remove the remote branch.

Does git branch delete only locally?

Delete a branch with git branch -d <branch> . The -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet. The branch is now deleted locally.

How do I delete a local branch without deleting the remote?

Unlike local branches, you can't delete a remote branch using the git branch command. However, you need to use the git push --delete command, followed by the name of the branch you want to delete.


2 Answers

Looking at the source it seems that the remote feature branch is deleted only if you call git flow feature finish with -F.

However, this fetches the remote before finishing the feature. From the docs:

-F fetch from $ORIGIN before performing finish

Otherwise you can delete the remote branch manually with:

git push origin :feature/new 
like image 180
Stefan Avatar answered Oct 04 '22 18:10

Stefan


May I suggest using the git-flow AVH Edition.

Like Stefan said, the original version only deletes the remote branch when you use -F, which is kinda strange. The AVH Edition fixes this quirky behavior, it will always delete the local and remote feature branch on a finish, unless you specify either

  • --keep, which keeps the local and remote.
  • --keeplocal, which keeps the local, but deletes the remote.
  • --keepremote, which keeps the remote, but deletes the local.

You can find git-flow AVH Edition on github.

like image 39
Peter van der Does Avatar answered Oct 04 '22 19:10

Peter van der Does