A pull request proposes changes on a branch separate from the main code base so others can review the changes before they are merged. This quickstart walks you through the simplest path to a pull request. You'll create a branch, make and commit changes, open a pull request, respond to feedback, and merge.
You can follow along on the GitHub website or with GitHub CLI by selecting one of the tabs above.
Branch or fork the repository
You'll start by creating an isolated place to work.
- On GitHub, navigate to the main page of the repository you want to propose changes for.
- Optionally, if you don't have write access, you'll need a fork. Click Fork in the top-right corner and follow the steps. Then, continue in your fork of the repository.
- Click the branch selector menu at the top of the file list. It probably says main. Type a new branch name and click Create branch new-branch-name from main.
-
To use GitHub CLI, you'll need to install it first. See GitHub CLI quickstart.
-
Clone the repository. Or, fork the repository and clone it locally at the same time.
-
If you have write access to the repository, clone the repository:
gh repo clone OWNER/REPO -
If you don't have write access, you'll create a fork first and clone it all at once.
gh repo fork OWNER/REPO --clone
-
Change to the cloned repository directory.
cd REPO -
Create and switch to a new branch.
git checkout -b YOUR-BRANCH-NAME
Author or edit your code
Make your changes on the branch. For your first pull request, keep the change focused and simple. Smaller pull requests are faster to review and easier to merge.
Try one of the following to make your changes:
- Edit files locally in your IDE or a text editor.
- Edit a file directly on GitHub by browsing to it and clicking .
Commit frequently
Save your work in small, meaningful commits. Each commit records a snapshot and a message describing the change.
git add .
git commit -m "Describe your change"
git push --set-upstream origin YOUR-BRANCH-NAME
When you edit a file on GitHub and are ready to commit, you'll enter a commit message and commit directly to your branch.
- Click Commit changes....
- In the Commit message box, enter a short description of the changes you made.
- Select the branch you're working on.
- Click Propose changes.
Your change will be added and committed to the branch.
Open your pull request
When your branch has the changes you want to propose, open a pull request against the base branch.
- On the main page of the repository, click Pull requests, then click New pull request.
- For the base branch, main is probably already selected and is typically the base branch you'll merge into.
- For the compare branch, select the branch that contains your changes.
- Click