How to tidy up after merging a Pull Request in your own repo – 023

Following yesterday’s tip, after a Pull Request has been merge, you’ll see a message suggesting that you delete the target branch.

Pull request successfully merged and closed - the readme-draft branch can be safely deleted

But why would I want to delete this readme-draft? What data do I lose if I delete it?

First, let’s talk about this possible data. The data around the conversation was captured as part of the Pull Request, which was only closed (not deleted), so you can still find it on GitHub.

Merged pull requests are considered closed when searching

Second, the data around the commits was merged into master, so that’s not being lost. Stay tuned to the end of this blog post to see a screenshot of these commits sticking around after I delete the branch.

Third, you most likely won’t need to use this branch again. Over time, as your number of merges increases, you’ll have a long list of branches.

switch branches dropdown using a scrollbar to list all branches

Hence it is considered good practice to clean up after your pull requests.

Fourth (and probably most importantly), this is a fundamental difference in how Git works compared to other source control systems. Branches are just pointers to a snapshot in time. More on this in upcoming tips when I start to play with Git command line concepts.

Lastly, you can always restore! Stay tuned to tomorrow’s tip.

Let’s delete this readme-draft branch. Click on the Delete branch button, and volia!

deleted the readme-draft branch message

And you can look a few lines up and see that the Pull Request still contains all the commits, regardless that the branch was deleted.

commits are still listed in the Pull Request after merge

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s