Recently, I tried to enter the open-source world, and contribute on GitHub. After doing some search and experimenting with one of my friends, I figured it out, and I will try to demonstrate it as easily as possible.
First of all, I will go with the installation guide for Git Bash, and explaining some common git terms.
- Git Bash Installation.
- Pull Requests.
- Adding & Committing.
- Steps To Make a Successful Contribution.
Git Bash is essentially a terminal, where you can implement git commands on.
You can download git bash from here, and choose the appropriate operating system that works for you.
According to GitHub Guides, “Issues are a great way to keep track of tasks, enhancements, and bugs for your projects.”
On any open-source project, navigate to the issues tab, and choose an open issue that you can solve.
Before working on any issue, you should add a comment to request solving it, then solving, after the owner of the project assigns it to you.
According to GitHub Docs, “A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.”
This is the core feature of collaborating.
After fixing the issue, you make a pull request, that suggests adding your fix to the project, and the project owner will review it, and respond to you.
If he accepted it, he will merge your fix with the project.
It’s a message that describes the changes that you did.
When you work on solving an issue, your commit message should include the number and the name of the issue.
After making any changes to your project, you should add it first to what’s known as “Staging Area” before committing it. The details of the staging area are not important to complete this process.
This is the operation in which we push our changes from our local repo, to the remote one.
It’s used to make the remote repo in sync with our local one.
This is a mandatory step, so that the commit message that you will make, will have an author.
git config --global user.name "Your name" git config --global user.email "Your Email"
On GitHub, press the green button, and copy the cloning link.
git clone [the url copied from the remote repo]
Make a new branch to your local repo, so we can make changes to the project inside this branch, and later we will ask the project owner to merge our branch with the main branch of the project.
The best practice is to make the branch name the same as the issue name.
git checkout -b [Your branch name]
We set up an upstream so that when we push our changes later, the default destination to push into will be our new branch.
git push -u origin [Your Branch Name]
Make the required changes to the project, that solve the issue.
This is an optional step, that shows the modified files (locally).
To add the changes, we do the following:
git add *
The * means add all the changed files, you can replace it with any file name that you changed before.
To commit a change, we do the following:
git commit -m "Your Commit Message"
When you open your GitHub forked repo, you will find this message pops up.
That's it. Congratulations on your first pull request! I hope this post was helpful for you, and helped on your open source journey. Good Luck!