All Pull Requests need to reference an existing Issue. If one does not exist, first create the Issue to address your fix or additions
โ If you do not have access to the repo, start by forking the repo. The following can be completed on your fork.
๐ If you do have access, the following can be done on the repo you are trying to edit.
- Suggested branch naming convention is Issue #, hyphen, descriptive name. E.g. '3-FixFormatting'
- Include detailed name/description
- Link to appropriate issue using 'Fix #'
- Add all accompanying screenshots, videos, and a detailed description.
This is an example using repository https://github.com/carletex/github-foo.git and branch name 3-FixFormatting. You will want to use your appropriate repository and branch name when following along.
git clone https://github.com/carletex/github-foo.git
Navigate to your new project folder, then we'll create and checkout our branch.
๐ If you want to use a branch other than main, you need to checkout that branch before proceeding!
The new branch should follow the naming convention of: Issue number, hyphen, descriptive title. E.g. '3-FixFormatting'
cd github-foo
git checkout -b 3-FixFormatting
โ Note this not only creates the new branch, but also performs the checkout.
You can view all branches at any time using
git branch
This will also display the active branch.
At this point, you can yarn install
if needed and make your changes to the project in your IDE.
Start by checking the status of your changes. In this example a new file named OurScripts.js was created.
git status
You can see our new file is not tracked, so let's add it.
git add .
โ Note we used the '.' wild card to add all our changes. You can instead use the file name to add one specific file.
Let's check the status again.
We see now that our new file is tracked and ready to be added to the commit.
Next we check the differences that our commit will include.
git diff --cached
๐ The output of get diff
and git log
can sometimes be very long. You can break using 'Q'.
We see it will add one new file and displays the contents of that file.
๐ค If these changes are not what you want to commit, make your updates now and perform another yarn add .
to update. Then check the status and differences again.
Everything looks good here, so let's commit.
git commit -m "commit message"
Looks like the commit was succesful, let's check the log.
git log
Looks good, but it is still only committed to local and we need it to go to origin. We can do this using the push command, the origin keyword, and the branch name.
git push origin 3-FixFormatting
Let's check the log again to see what changed.
We now see it's pointing to the 3-FixFormatting branch on origin. Now we can head to the repo on the GitHub website and create the PR.
After clicking Compare & Pull Request you can enter a new message and description for the Pull Request, and change which branch you will create the PR against. We're going to use the main branch.
In the description box, start by typing 'Fix #', this will open a list of Issues. Choose the appropriate open Issue here to link the Pull Request.
Also add any relevant screenshots, explanation videos, and a detailed write-up in the description box, then create the Pull Request.
Done! Now just keep an eye on your GitHub account for notifications of any comments or change requests on the Pull Request and respond or update as necessary.