[Git] How to Contribute to Open Source Projects Step by Step

image.png

  • Go to a open source project of your interest and press the fork button

image.png

  • Click create fork

image.png

  • Press Code button and copy the url

image.png

  • Now go to your IDE. Here I will use VS Code
git clone "copied url"

image.png

  • We can see that everything is cloned into the local repository

image.png


How to update my local repository

  • if other open source contributors make changes, then I will need to update my local repository
  • Otherwise there will be a conflict when I ask for pull request

step-2-1-conflict.png

  • Go to the original project repository and copy the project url

image.png

  • Now go to your IDE terminal and type this
git remote add upstream "original project repository url"

# git remote -v shows remote repositories connected to your local repositories
git remote -v
  • So it seems like original repository url is already there
  • Now we can bring any recent changes made by other contributors
# bring latest updates from 'upstream'
git fetch upstream

# go to the branch you want to update
git checkout master

# merge the latest update and my changes
# git merge remote repository/my branch name
git merge upstream/master

# update my local repository
git push origin master

image.png


Make a branch and Contribute

  • instead of using master or main branch, it's better to make a branch to show what issue you are trying to solve
git checkout -b "branch name"
  • This is same as:
git branch "branch name"
git checkout "branch name"

image.png

  • Commit and push your changes
git add 

git commit -m "Add visual studio code for code editor"

git push

image.png

image.png

image.png

image.png

  • Press Create pull request button and it's all done!

image.png

  • All you have to do is wait to see if your pull request is approved

Did you find this article valuable?

Support Christy Choi by becoming a sponsor. Any amount is appreciated!