Open Source Journey — Submitting your first pull request

Brad McCoy
5 min readOct 4, 2021

--

Wanting to make your first open-source contribution? All contributions are a big help no matter how small they are. This blog is to help those starting out in the open-source community to help submit their first pull request whether it's for Hacktoberfest or for any open source project.

Pic from: http://www.ardiluzu.com/

I will assume you have already installed git on your computer and have set up your ssh keys on your GitHub account.

The very first thing you should do is go over the repo before you fork it, if there is a code of conduct file or a contributing.md file, then go over it, it will go over how the maintainers would like you to make your contributions, from how to make issues, name your branches/pull requests and documentation. This is important as it will make the maintainer's and approver's job easier.

If you have any questions or need help you can ask me on Twitter here and you can also follow me on GitHub to see examples of pull requests I do here

Table of Contents

  • Fork the repo
  • Clone the Fork with git clone
  • Make a new branch with git checkout
  • Configure your name and email with git config
  • Add your name as a contributor
  • Check your changes with git status
  • Add your changes with git add
  • Commit your changes with git commit
  • Push your changes with git push
  • Create your Pull Request!

fork the repo

Navigate to the repository that you want to contribute to and click the fork button. This will fork a copy of the repository to your GitHub name.

git clone

Now that you have forked the repo you can now clone it from your account, and cd into the folder to start working on it.

git clone git@github.com:bradmccoydev/how-to-dok.git
cd how-to-dok

git checkout

We now need to create a new branch, for this, we can use the git checkout command. For naming conventions, it is good to read through the repo to see how they do things, normally you can find it in the CONTRIBUTING.md file, or you can look at other pull requests in GitHub to see how people are naming branches, etc.

git checkout -b 30/add-bradmccoydev-to-contributors

git config

The first thing you need to do is configure your name and email that you want to show up on your commits, this will show up on the repository history that you are committing to.

git config --global user.name "<name>"
git config --global user.email "<email>"

Add your name as a contributor

The contributors will either be straight in the readme, or in a CONTRIBUTORS.md file. Open up your favourite editor and add your name!

* [Brad McCoy](https://github.com/bradmccoydev)

git status

This command is used to check the status of code that you have changed, it is useful to use before you add your changes before committing them.

git status

git add .

Now we have made the changes we need to add them. We can use git add . to add all the changes. There are a lot of ways you can add files but that is the easiest.

git add .

git commit

Now that we have added the files that we want to commit we can now commit them most open source projects want you to sign the commit that is not often documented you can do this by simply adding the -s parameter. You can now use the git status command again to check

git commit -m "add brad mccoy to CONTRIBUTORS.md" -s

git push

We are now ready to push this change to your remote git repo. We can use git push origin <your-branch-name> to push it up. This will normally give you a link at the end to create a pull request. If you don't get it you can go to the original repo and create one.

git push origin 30/add-bradmccoydev-to-contributors

Create your pull request

The last step is to create the pull request. If there is an issue associated with it you can comment “This closes issue 30” this is helpful for the maintainers.

Congratulations!

You have now submitted your first pull request. After the pull request is approved and merged you will be able to see your code in the main branch!

--

--

Brad McCoy
Brad McCoy

Written by Brad McCoy

CD Foundation board member | CNCF Ambassador | Kubernetes Release team 1.28 comms lead

No responses yet