flowchart LR
Fork[Fork the project]-->branch[Create a New Branch]
branch-->Edit[Edit file]
Edit-->commit[Commit the changes]
commit -->|Finally|creatpr((Create a Pull Request))
1. Fork the project:
- Click the gray Fork button at the top right of the previous page. This creates your copy of the project and saves it as a new repository in your GitHub account.
2. Create a New Branch:
- On your new repository's page, click the gray main button in the upper left to reveal a dropdown menu.
- Enter the name of your new branch in the text box. (Branch names usually refer to what is being changed. Example: nameAdd). -Click on Create branch , which will automatically take you to your new branch. You can make edits on the main branch, but this may cause issues down the line. The best practice is to create a new branch for each separate issue you work on. That way your main branch remains in sync with main branch.
3. Make Edits:
- Navigate to the file you need to edit (e.g.,
README.md
). - Use the pencil icon to open the file for editing.
- Add your changes (e.g., your name and GitHub profile link), keeping the format and order consistent.
4. Commit Changes:
- Write a short and descriptive commit message summarizing your changes (e.g., "Added my name to contributors list").
- Save the changes to the branch you created.
5. Raise a Pull Request:
- Click
Pull Requests
option in your forked repository (which is the third option at the top of this page after the optionsCode
andIssues
). - Click the green New Pull Request button. This will prep the new pull request for you by auto-filling the base repository: base with 'main' And auto-filling your head repository: compare with your repository: main
- Click on your head repository's
compare
dropdown, and switch branches from your 'main' branch to<new branch name>
. - Finally, click the green
Create Pull Request
button. Great job! You did it!
- Click the gray Fork button at the top-right corner of the repository page.
- This creates a copy of the repository under your GitHub account.
-
Navigate to your GitHub profile and locate the forked repository.
-
Click on it to open the repository.
-
Click the green Code button, select HTTPS or SSH, and copy the URL.
To download the forked repository to your computer, run the following commands in a terminal:
git clone <repository-url>
Example:
git clone https://github.com/<your-username>/<repo-name>.git
- Navigate into the cloned folder:
cd <repo-name>
- Open the project folder in your preferred code editor (e.g., VS Code, Sublime Text).
- Create a new branch with a unique name. Your username makes a good choice:
Example:
git checkout -b <new-branch-name>
git checkout -b add-my-name
- Identify the file you need to update (e.g.,
README.md
) or any other relevant file in the repository. - Open the file and make the necessary changes. For instance, if required.
- Stage the changes you made:
Alternatively, stage all changes:
git add README.md
git add .
-
Commit your changes with a meaningful message:
git commit -m "Improved Readme.md"
-
Check the status of your repository to ensure everything is committed:
git status
Example response:
On branch <new-branch-name> nothing to commit, working tree clean
- Push your branch to your forked repository:
If necessary, rename your branch and push:
git push origin <new-branch-name>
git branch -M main git push -u origin main
- On GitHub, navigate to your forked repository.
- At the top of the files section, you’ll see a Compare & Pull Request button. Click it.
- Review the comparison page to ensure the correct branches are selected (your branch and the main branch of the original repository).
- Click the green Create Pull Request button.
- Your pull request will be reviewed by the maintainers of the original repository.
- Once approved, it will be merged into the main repository.
Warning: If you get an error message like the one below, you probably forgot to fork the repository before cloning it. It is best to start over and fork the project repository first.
ERROR: Permission to https://github.com/<repo-name> denied to <your-github-username>.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and that the repository exists.