Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing branches and delete branch in Git after successful pull request

Tags:

git

github

I created a branch "newbranch" from the master, and then pushed back to the origin. I then created a pull request which was accepted and merged into master.

At this point should I delete "newbranch" from my local and re pull from master to begin working on something new?

What is the proper flow, after a branch has been accepted to master?

like image 604
FluxEngine Avatar asked Dec 04 '25 23:12

FluxEngine


2 Answers

Update April 2013:

See "Redesigned merge button" and "What do you do with your branch after a pull request on GitHub?":

The branch is now deleted for you

new merge button


Original answer (February 2013)

The blog post "Tidying up after Pull Requests" is even more explicit:

The only trouble is that we end up with a lot of defunct branches after Pull Requests have been merged or closed.
From time to time, one of us would clear out these branches with a script, but we thought it would be better to take care of this step as part of our regular workflow on GitHub.com.

Starting today, after a Pull Request has been merged, you’ll see a button to delete the lingering branch:

enter image description here

The only case when you wouldn't want to delete that branch is:

  • if you intent to expend on your current patch, reusing the same branch
  • or you have started a few commit that hasn't been merged/accepted, and that would be lost if you deleted the branch:

If the Pull Request was closed without being merged, the button will look a little different to warn you about deleting unmerged commits:

enter image description here

That would avoid any accident, deleting a branch too soon.

like image 66
VonC Avatar answered Dec 06 '25 17:12

VonC


When it is merged into master, you can safely delete it.

like image 30
KingCrunch Avatar answered Dec 06 '25 15:12

KingCrunch