Open a Pull Request on GitHub

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.

gif of following the directions below

  1. Push your commits to the remote, and set a tracking branch. Type:

     git push -u origin <BRANCH-NAME>
    
  2. Enter your GitHub username and password, if prompted to do so.
  3. Create a Pull Request on GitHub.
  4. Fill out the body of the Pull Request with information about the changes you’re introducing.
I need a refresher

Create a Pull Request

  1. After pushing your local changes to your remote repository, point your browser to your repository on Github.com.
  2. Click the Pull Requests tab.
  3. Click New pull request.
  4. In the base: dropdown, select master.
  5. In the compare: dropdown, select the branch you recently pushed to the repository.
  6. Click Create pull request.
  7. 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

Pushing Changes

  1. :white_check_mark: Create a branch
  2. :white_check_mark: Add commits
  3. Open a Pull Request :arrow_left: (This section deals with this step.)
  4. Collaborate, and make more commits
  5. 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.

  • git clone
  • git fetch
  • git pull
  • git push

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 git push.

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 git push.

Stuck? Open an issue in the repository for this class and mention @githubteacher for help from one of the GitHub trainers!
Continue