The first step you want to do in-order to contribute to an open source project is to fork the project. This will create a copy of the project under your account.
You'll see the fork option on the top right hand side of the screen.
- Click on the fork button.
Now, you have to clone the forked repository. This will create a local copy of the project on your machine.
You can do this in 2 ways:
- OPTION 1
- Click on the clone button.
- Download the ZIP and then extract it.
- OPTION 2
- Click on the clone button.
- Copy the link under HTTPS section.
- Open terminal/git bash/command prompt.
- Type -
git clone
- Now paste the link.
- The resulting command should look something like this:
git clone https://github.com/YOUR_USERNAME/first-pr-repo.git
Let's start working on the project now! We need to change directory into cloned folder by typing the following command.
cd first-pr-repo
Now, BEFORE CHANGING ANYTHING, make sure you're working on a different branch and not in master. To create a new branch, from the terminal inside your current project directory type the following command.
git branch YOUR_GITHUB_USERNAME-profile
Obviously you'll have to replace the YOUR_GITHUB_USERNAME with your GitHub username.
(You can give any name to your branch which describes the purpose of the branch. Since here we're adding your profile to the profiles directory, we'll simply give the name of the branch as above.
eg: git branch nirbhayvashisht-profile. )
Once you have created the new branch we'll change the current branch from master to your newly created branch.
Execute the following command on your terminal.
git checkout YOUR_BRANCH_NAME
- Move into the profiles directory in cloned project.
cd profiles
- Create a new file called YOUR_USERNAME.md using the following command.
touch YOUR_USERNAME.md
- Navigate into the project directory (through your file manager) and open this file in your favourite editor.
- fill the details as shown below:
---
username: YOUR_USER_NAME
fullname: YOUR_FULL_NAME
---
- Save and clone the file.
NOTE: This is just a way of simulating - you making changes into the project file.
- Now we need to stage all the changes we made.
- Open the terminal again and inside the project directory and execute following commands.
git add .
- The above command staged all the changes, now we need to commit them with a suitable message. You can commit using the following command.
git commit -m "YOUR_COMMIT_MESSAGE"
Example:
git commit -m "Hey, I just added my profile in the profiles directory"
Let's push the changes to your repository on GitHub! Execute the following command to push all the changes to the forked copy in your GitHub account.
git push -u origin YOUR_BRANCH_NAME
Now open your github account to make a pull request.
- Click on compare and pull request.
- Write a meaningful description and click on Create Pull Request.