100 Days of Joy: Day 4

What is a GitHub Pull Request? How do they work? Why do we need them?

Today's topic hit me while I was streaming on Twitch and building my portfolio site. I realize that when I went through bootcamp, I learned the Git Flow without really understanding what a Pull Request actually is, how they work and why we need them.

WHAT IS A PULL REQUEST?

According to GitHub, (guides.github.com/activities/hello-world/#:..):

Pull Requests are the heart of collaboration on GitHub. When you open a pull request, you're proposing your changes and requesting that someone review and pull in your contribution, and merge them into their branch.

Pull Requests are useful for contributing to open source projects and managing changes to shared repositories. If someone forks your repo, Pull Requests help start code review and enables you to work on changes before they are merged into the main branch.

What made me start to ponder upon Pull Requests was the question "Do I really need a Pull Request at this point in building my portfolio? The answer was NO. Since this is the second or third time I've tried to build this portfolio site, I decided to make another branch to my repo and titled it "TwitchStream1," instead of starting a completely new repo. That way I can finish one version of the site and still work on the previous versions I dropped (if I ever come back to them).

HOW DO PULL REQUESTS WORK?

After you've opened a new branch, accomplished whatever work you needed to and are ready to merge your changes into the main branch (In my case, when I'm ready to merge "TwitchStream1" into "main" its time to follow these steps:

HOW TO OPEN PULL REQUEST:

This starts the Pull Request sequence. When working on a team, this sequence enables other people (Collaborators) to work on your code. 1. Open Pull Request for the changes you made. Click the "Pull Request" tab from the Pull Request, then click the green "New Pull Request" button. 2. Compare the branch you are on to "main" 3. Look over your changes in the diff on the "Compare" page to make sure they are what you want to submit. 4. Give your Pull Request a title and description 5. Click "Create Pull Request" button.

HOW TO MERGE A PULL REQUEST:

Merging your Pull Request brings all your changes from whatever branch you are working on into the "main" branch. It is possible to have merge conflicts, which is a thing I will probably blog about some other time. 1. Click on the "Merge Pull Request" button to merge the changes into "main." 2. Click "Confirm Merge." **Delete the branch since changes have been incorporated, by clicking "Delete branch."