delete a 'feature' branch using gitflow without merging into master branch
Asked Answered
D

3

47

I am using the Git GUI called 'Souretree' by Atlassian and in particular the 'Gitflow' module to manage various branches.

I just created a 'release' branch that I don't want to merge back into either the master or develop branches. How do I get rid of it ? Can I just delete it ? My concern is that I mess up the gitflow config.

I have only made one commit to this branch which i don't care about.

Disillusion answered 3/3, 2014 at 1:58 Comment(0)
D
58

It seems that I can just delete the branch according to the following sources: Evan Hahn dominiksymonowicz

To quote Evan:

To trash a branch using git-flow , simply delete it like you'd normally delete a Git branch:

git branch -D whatever/branch/you/wanna/delete

Note that this does a forced delete, so anything you did on that branch will be lost. You can be safer with the lowercase -d flag instead.

So using the sourcetree GUI interface i first changed to another branch ( in my case develop) and then simply right clicked on the release branch name in the list of branches in the left hand panel and selected Delete release/releaseName. This gave me the option to do so with as a Force Delete, which in my case was necessary as I wanted to delete the unmerged commits as well.

Disillusion answered 3/3, 2014 at 3:11 Comment(2)
this doesn't clean the branch remotely. You will notice that if you try to run again git flow feature start whatever/branch/you/wanna/delete you will get a "Fatal: Branch 'whatever/branch/you/wanna/delete` already exists. Pick another name"Supersensitive
Deleting the branch using raw Git is fine and everything, but it leaves orphaned entries in your local config file. Since there is no "git flow feature delete" I usually issue a "git config --local --edit" and have to manually remove the [gitflow "branch.feature..."] entries I don't want anymore. There is no ill effect leaving them in there, I just don't like the clutterMoluccas
E
29

I actually wrote the below in a how to article for a development team last week, so I can share it here:

Delete a local branch

git branch -d branch_name

Delete a remote branch

git push origin --delete branch_name

If you don't delete the remote branch then you'll either have a problem when attempting to create a branch with the same name, or you'll leave a branch that needs to be pruned in the future.

Also is it assumed that your remote is called origin, but if different then you'll need to change that above.

Eventide answered 22/1, 2018 at 15:59 Comment(0)
S
2

To remove the feature branch. First you have to checkout or switch to another branch.. if you at the same branch which you wanted to remove or delete.

  • git checkout <another_branch_name>

after shift to another branch you are ready to remove the feature branch with command

  • git branch -d <Removable_branch_name>
Shoifet answered 23/9, 2021 at 10:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.