Contributing to Git projects is an essential skill for developers working collaboratively. It involves adding code, fixing bugs, or improving documentation in a project hosted on GitHub or similar platforms. This chapter will guide you step-by-step.
Before contributing to a Git project, it’s important to understand:
CONTRIBUTING.md
file.Forking creates your copy of the repository under your GitHub account.
Fork repository comes under your account.
Now I can contribute on this repository and create pull requests for the Original Repository from this forked repository.
Forking creates your copy of the repository under your GitHub account.
Always create a new branch for your changes to keep the main
branch clean.
Check the current branch:
git branch
Create and switch to a new branch:
git checkout -b branch-name
git checkout -b fix-typo
Edit the files using a code editor. For example:
README.md
.Edit the files using a code editor. For example:
README.md
.Stage the changes:
git add .
Commit the changes with a descriptive message:
git commit -m "Fixed typo in README.md"
Push the changes from your local branch to the corresponding branch in your forked repository:
git push origin branch-name
git push origin fix-typo
Propose your changes to the original repository.
Open the main repo in Pull request tab , your created pull request will come.
Now its up to owner of repository they will approve or reject your changes.
README.md
and CONTRIBUTING.md
files for guidelines.Permission Denied
Outdated Fork
PR Rejected
Contributing to Git projects is a valuable skill that allows you to collaborate with others and improve open-source projects. By following these steps, you can confidently contribute, handle conflicts, and propose changes effectively. Mastering these techniques ensures a smoother and more impactful contribution experience.Happy coding !❤️