Today’s tip completes the workflow started in Tip 019 – How to create a pull request for existing branch in your own repo. The scenario is you have a readme you’ve created on a branch and it’s ready to be merged. Even though you are the only contributor to the repo, you still have to use a Pull Request to merge, if you are using GitHub.com to handle the merge instead of command line.
Remember, a pull request is the start of a conversation, even if you are the only developer on the repo. Reviewing your own Pull Requests is kinda like practicing conversational French by yourself. Nothing wrong with practicing your vocalization, but a Pull Request was designed to get points of view from other people. Consider the following true-story exchange:
Host family: “Est-ce que tu veux dîner?” (Want to go to dinner?)
Me: “Non, J’ai faim,” as I shake my head no saying “I’m hungry”
In yesterday’s tip we saw that master (the base branch) has 13 commits (at the time of this blogging),
but readme-draft branch (the target branch) has 16 commits.
Using my random-example repo, you’ll watch me merge Updated the readme (PR #1) into the master branch in the steps below.
Two things to note
- There are no conflicts with the base branch (aka master) because we’re adding a new file that doesn’t currently exist in master
- There are options to how we could merge this pull request (the dropdown arrow in Merge pull request), but you’ll read more about these in upcoming tips.
Clicking on Merge pull request presents you with a form to fill out
“What?? Another form?? Didn’t I already fill out a form when I created the Pull Request???”
My thoughts exactly When you created a Pull Request, you filled out a form to start a conversation. This form is documenting the merge. These comments will live in the Git log, whereas the Pull Request title and comments live on GitHub.com.
In the scenario where you are making a code contribution to someone else’s repo (i.e. a repo you don’t have commit access to), you wouldn’t see these options to do the merge. But in the case where you want to merge branches in your own repo, you are documenting that you approve and merge your own code, aka you’re merely having a conversation with yourself!
Use the default comments and click confirm merge and you should see the following message:
Going back to the repo homepage, you know see that master has gone from 13 commits to 17 commits (13 original commits + 3 commits from readme-draft + 1 commit for the merge = 17 commits)
I’m covering the easiest scenarios right now to get warmed up, and also, because I’ve never tried playing with the other Merge pull request dropdown options yet. But that’s why I’m doing this series… to force myself to learn!