Git Commands for Open-Source Contribution
Quick reference of git commands during contribution
The step-by-step guide to contributing to open-source projects:
Fork Repository: Top-right corner second button is a Fork.
Clone Repository: Copy the URL of the repo to clone in your local directory. Open Git Bash, select the directory where you want to clone your repo, right-click and open Git Bash.
git clone paste-your-URL
Create a new branch:
Change to the repository directory using:
cd your-repo-name
Create a branch using
git switch
orgit checkout
command:git switch -c your-new-branch-name
or
git checkout -b your-new-branch-name
Make your changes (here you can find issues or improve code or add your name to the contribution list).
Add those changes to the branch using the
git add
command.To add all changed files use:
git add .
Add specific changed file use:
git add changed-file-name
Commit those changes using
git commit
command:git commit -m "Add your message here"
Push your changes to GitHub using
git push
command:git push -u origin your-branch-name
Go to your repository on your GitHub, you'll click
Compare & pull request
button to add your PR.Finally, add your PR title and comment, then you'll click
Create pull request
button to complete your first pull request (PR).
Congratulations ๐ you have completed your first contribution.