If I could go back in time, this is one of the first tips I’d tell myself about using GitHub. Don’t think of a Pull Request as the final submission. Think of a Pull Request as the beginning of a conversation about the code you want to merge. It’s difficult to appreciate how a Pull Request is the start of a conversation if you are the only developer on a project, so you’ll see more tips on using PRs with other users later in the year.
At first, creating a Pull Request feels like you’re submitting a homework assignment. You might think that once you turn it in, that’s it. But that’s actually not the case with a Pull Request!
You can still go back and make edits to your Pull Request by making commits to its branch.
From yesterday’s tip, you followed along how to create a README.md file in a new readme-draft branch, and create a Pull Request to merge it into master. But let’s say you want to add more content to your README.md.
First, you’ll want to switch to the readme-draft branch using the Branch:master dropdown button.
In the readme-draft branch, you can click on README.md file and then the Edit this file button on the far right.
In my random-example repo, I’ll add the following sentences to the README.
I’ve switched to real-world sample code because I feel it is easier to grasp Git-related concepts when actual code is being used, rather than using “Hello from File1” or my joke examples. I learned in UX grad school that the more applicable the new information is made, the easier it will be to learn new concepts. You need to have “a hook to hang your hat on,” as the professor would say. E.g. I didn’t find out that cognition means the study of how the brain works, until I was in the 2nd week of class (which was a class called “Cognition”). I was completely lost; whereas all the psychology majors around me were learning the course material faster than Neo learning Kung Fu. My classmates already had a hook to hang their hats on, whereas I was learning that people study this stuff without going to med school.
Now commit these changes to the readme-draft branch (not a different branch).
So what’s happened?
Let’s pretend we never created a Pull Request. If you go to the readme-draft branch, you see your changes, just as you’d expect from previous tips.
But we already created that Pull Request, so let’s take a peek at it.
Go to the Pull Requests tab, and click on Updated the readme to view the Pull Request.
The item circled is the commit we just did. Remember, this list above is of commits and not the files that were modified. I can’t recall how many times I’ve had to silently remind myself this.