Creating a pull request with Github

Hey all ! This blog will be about how easy it is to create a pull request on github. In this tutorial I am contributing to YearOne which is a great resource for new devs like myself to find jobs, network, ask questions, get feedback and so much more.

  1. Fork the repo.

After forking your chosen repo, you’ll be redirected to a new page with a copy of the original repo, but now you have a repo with your github name and the repo added to your repositories.

2. Clone the repo to your machine.

There is a difference between HTTPS and SSH but Github encourages HTTPS. If you’d like to read about it, here’s a good article.

3. In your machine terminal, either directly from the dock or opening it in your code editor. Enter the command to put the repo onto your machine using ‘git clone [info that was copied]’ then enter.

it’s alive!

4. Cd into the directory and enter.

Now we are in the repo

5. I am now in the YearOne-prep-challenges folder and I enter the command ‘code .’ , VS Code pops up with the repo exactly the way it is on Github.

6. After adding my changes to different files, I open up my terminal within VS Code, command + ~, the button directly under the esc button. Enter the commands to push changes to my copy of the repo on my Github account.

  • git add .
  • git commit -m ‘your message’
  • git push

If all goes smoothly, the result should look like the screenshot and back in your copy of the repo it show the time that has elapsed since you pushed changes & the files that you changed along with your message.

7. In the now updated copy of the repo with my changes, I have the option to contribute or fetch upstream. Click ‘open pull request’. I pushed my copy of the repo twice, so I am 2 commits ahead.

I am also 1 commit behind, scroll to end to fix that.

8. I’ve given a description of the changes I’ve made. It shows the files that I made changes to and the elapsed time since I pushed my commits.

The owner of the repo will let me know with comments if I need to make changes before approving my changes to the main repository.

I thought pull request were a lot more complicated but it’s pretty simple ! If my changes are approved and gets merged with the main repo, it’ll be my first open source I’ve contributed to!

I’m adding some more info on how to get changes from the original repo onto your machine. Since there are several people on this project, 2 others committed changes before my pull request. So I had to get those changes first and then make the necessary changes to my submission.

  1. Create access to the original repo. On my local machine my branch is called main previously known as master. To create this access to the original repo, type in your terminal `git remote add upstream [original repo url]`
  2. After this upstream is created, then `git fetch upstream`

3. Enter the command `git remote -v`and you should see your repo with your username and the upstream just created with their username.

4. Get the changes from the original repo onto your machine with `git merge [upstream/your branch your branch]`. The name of the original repo does not have to be upstream but it is convention and best practice to do so.

Since I made changes before fetching from the original repo, I get the warning to stash my changes, to do this, simply enter `git stash` to save your changes.

The terminal lets you know in which files there are conflicts, once you navigate to those files you should see the changes from the original repo highlighted, with prompts. Also if you made any changes, those will also be highlighted. For my case I accepted both changes which is mine and the new submissions, and updated what I needed to in my submission.

5. Finally just push up the updated that code to your directory.

  • git add .
  • git commit -m ‘updated’
  • git push

When you head back to your repo on github you will see the new changes from the original repo that you fetched plus your changes. The owner of the repo has seen my changes and my submission is now approved and in the main repo.

YaY !!!

I hope this was helpful ! Happy pulling, pushing, committing and all things dev related!

The sassy developer