Now that you have made some local commits, it is time to send your changes to the remote copy of your repository on GitHub.com and create a Pull Request.
Push your commits to the remote, and set a tracking branch. Type:
git push -u origin <BRANCH-NAME>
- Enter your GitHub username and password, if prompted to do so.
- Create a Pull Request on GitHub.
- Fill out the body of the Pull Request with information about the changes you’re introducing.
I need a refresher
Create a Pull Request
- After pushing your local changes to your remote repository, point your browser to your repository on Github.com.
- Click the Pull Requests tab.
- Click New pull request.
- In the base: dropdown, select
- In the compare: dropdown, select the branch you recently pushed to the repository.
- Click Create pull request.
- Modify the Title and Description of the Pull Request to identify the changes this Pull Request is introducing to the master branch and your repository.
Tell me why
- Create a branch
- Add commits
- Open a Pull Request (This section deals with this step.)
- Collaborate, and make more commits
- Merge the Pull Request
We just created a branch locally and added commits. The remote repository that’s hosted on GitHub.com isn’t aware of these changes automatically.
In fact, there are only 4 network commands that actually cause the local or remote repositories to update.
This won’t happen automatically, so when we are ready to open a pull request, we need to push up our branch. The command we will use is
git push -u origin <BRANCH-NAME>.
The syntax is a little complicated here. Let’s break it down.
git push is the root part of the command. It tells Git that you want to update the remote branch with your current, local branch.
-u is short for
--set-upstream. This sets a relationship between the branch on the remote and your branch locally, so that in the future you only need to type
origin tells Git where you want to push.
origin is just a shortcut for the URL of the repository. You can type
git remote -v to see what it is pointing to.
<BRANCH-NAME> tells Git to create a branch on the remote with the same name as your local branch. You should replace this with your branch’s name.
The good news is, you only need to do this long command once. If you have pushed this branch before or it already exists on the remote, you can simply type