× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

how to delete a git branch that has not been merged

Daniel Hug
Dec 03, 2015
<p><img alt="Git logo" src="https://git-scm.com/images/logos/downloads/Git-Logo-2Color.png" style="height:190px; width:455px"></p> <p> </p> <p>In Git, trying to delete a branch that has not been merged, will give you this warning:</p> <blockquote> <p>error: The branch 'feat-a' is not fully merged.<br> If you are sure you want to delete it, run 'git branch -D feat-a'.</p> </blockquote> <p>Feature branches are often deleted after having been merged into master. In this case though, the branch is being deleted because the feature is being aborted.</p> <p>Since none of the changes to branch <code>feat-a</code> are wanted it is safe to <strong>force the delete with the capitalized <code>-D</code> option</strong>:</p> <pre>git branch -D feat-a</pre> <p>Then, if the same branch is on a remote like on Github you can delete it there too:</p> <pre>git push origin --delete feat-a</pre> <p><code>origin</code> above is the name of the remote. List the available remotes with <code>git remote -v</code></p>
comments powered by Disqus