This page is a work in progress. PRs welcome!
TODO: I'm going to make instructions clearer, and add screenshots
- Start by visiting the GitHub page of the repository you wish to contribute to.
- In the top-right corner of the page, click the "Fork" button. This will create a copy of the repository under your GitHub account.
- On your forked repository's main page, click the green "Code" button. Copy the URL provided.
- Open your terminal or command prompt and navigate to the directory where you want to clone the repository. Enter:
git clone [URL you copied]
This will create a local copy of your forked repository on your machine.
Enter:
cd [repository-name]
To keep track of the original repository (often called the "upstream"), enter:
git remote add upstream [original repository's URL]
Always make changes in a new branch instead of directly on main or master. To create and switch to a new branch, enter:
git checkout -b [branch-name]
Choose a descriptive branch name related to the changes you're planning to make.
Edit, add, or remove files as needed using your preferred text editor or IDE.
Stage your changes with:
git add .
Commit your changes with a descriptive message:
git commit -m "Brief description of changes made"
Push your changes to your forked repository on GitHub:
git push origin [branch-name]
- Go back to your forked repository on GitHub.
- Click the "New pull request" button (often GitHub will also present a quick link to create a PR from your recently pushed branch).
- Ensure the base repository is the original repository you want to contribute to, and the head repository is your fork. Also, make sure the branch shown for your fork is the one you just pushed.
- Fill in the PR title and description, detailing your changes and the reason for them.
- Click "Create pull request".
- The maintainers of the original repository will review your PR.
- They might request some changes. If they do, repeat steps 6-8, and the PR will automatically update with your new changes.
- Engage in any discussions, answer questions, and make necessary changes as needed.
Before starting new work, it's a good practice to fetch and merge changes from the upstream (original) repository:
git checkout main
git fetch upstream
git merge upstream/main
git push origin main
Once your PR is merged, you've made a successful contribution!