28
How to Make an Open Source Github Contribution π―ββοΈ
In this post, we'll go over the basics of how to make your first Github contribution. If you would like to test out your skills, and make a test contribution, head over to Merge Me, an open source repository that allows you to practice making your first pull/merge requests. You'll find these same directions once you open up the index.html file. Let's get started!
Fork and clone the repository to your local environment.
Start by making a pull request. This will keep all the files locally up-to-date with the remote repository, in the circumstance other developers you may be working with have made any new changes. To do this, start off by confirming you are in the main branch, and then in your command line type:
user@Users-MacBook_Air: git pull origin main
Running this command will pull all the files from the remote branch, updating your local branch to match any changes made. It's always a good idea to do this, especially when working with others as you don't know what changes could have been made since you last accessed the branch.
user@Users-MacBook_Air: git checkout -b (YOUR BRANCH NAME)
When naming your branch, it's good practice to name it after what you're doing/in relation to the changes being made. So, if you were to make a pull request to add a README.md file into a repo, you might name that branch 'readme-md'.
If you've done it correctly, you should have received the following message in your terminal:
If you've done it correctly, you should have received the following message in your terminal:
switched to new branch '(YOUR BRANCH NAME)'
Once you are inside your newly created branch, you can finally add in your own code! So, contribute! Go! Be Free!
After you've made the most meaningful contributions of your life, you're going to want to save all those beautiful changes. Now we're going to do something that should hopefully feel a little familiar. In your terminal type:
user@Users-MacBook_Air: git add .
user@Users-MacBook_Air: git commit -m "A MEANINGFUL COMMIT MESSAGE EXPLANING WHAT YOU ADDED"
To avoid this, you'll instead push your changes to your newly created branch. This can be done by adjusting the good ol' 'git push' command to the following:
user@Users-MacBook_Air: git push origin (YOUR BRANCH NAME)
You should receive a message back in your terminal confirming that your code was pushed up to your newly created branch.
You should be lead to a page that displays your commit message! You'll see an option to leave a message underneath your commit. If you are working with others, it is great coder common courtesy to leave a nice little message further detailing your commit and why you added it in the first place. Again, this avoids bugs and confusion later.
After you've left a message, you're going to create a pull request. You should see a 'Create pull request' button underneath the message box, give that a click. By doing this, you're putting a request to the repository owner that you would like to push your changes to the main branch of the repository. Doing so will also notify all the other developers working on this repository that a new push request has been made. You can even assign reviewers to be notified of your push request, which can be done under the 'reviewers' tab.
If everything went smoothly and you contributed something (somewhat) meaningful, your code will get pushed, merging with the main branch.
Congratulations, you just made your first contribution. Do a dance to celebrate.π
It doesn't seem so bad after all, does it? If you followed along with this post while making your first contribution, awesome job! If you haven't made yours yet, get on out there and do it! Try it out on the Merge Me, where you can collaborate with other developers like you!
I hope this blog post has helped you in your contribution journey, as much as I hope to see your contributions in Merge Me, happy coding! :)
28