title: Apply Remote Commits to a Local Pull Request
body: <p>I have forked an active open source project that is on GitHub to my account. I then cloned my GH repo to my local machine. I do regular fetches of the upstream master branch to keep my local copy in sync.</p>
  <p>I’m interested a pull request for a significant new feature on the upstream repo that is currently being reviewed and changed. I want to copy the pull request to my local machine so I can review and analyze this code. I will not be submitting any changes to this work.</p>
  <p>I’ve fetched the pull request with this command and result:</p>
  <pre><code>$ git fetch upstream pull/5737/head:pr-5737 
  
  remote: Counting objects: 4, done. 
  remote: Total 4 (delta 3), reused 3 (delta 3), pack-reused 1 
  Unpacking objects: 100% (4/4), done. 
  From https://github.com/OrigProj/repo-name 
  * [new ref]     refs/pull/5737/head -&gt; pr-5737
  </code></pre>
  <p>The result is a new branch called ‘pr-5737’ for the pull request.  The project devs have now made additional commits to the pull request as they work on it. I can get the new commits to the pull request down to my local machine with these commands:</p>
  <pre><code>$ git checkout pr-5737 
  Switched to branch 'pr-5737' 
  
  $ git fetch upstream pull/5737/head
  
  remote: Counting objects: 4, done. 
  remote: Total 4 (delta 3), reused 3 (delta 3), pack-reused 1 
  Unpacking objects: 100% (4/4), done. 
  From https://github.com/OrigProj/repo-name
  * branch         refs/pull/5737/head -&gt; FETCH_HEAD
  </code></pre>
  <p>I cannot figure out the command to ‘merge’ these newly fetched commits to the head of the pull request branch. I don’t want to merge the pull request into the master branch. I want to keep the separate branch, pr-5737, updated. What command do I use?</p>
  <p>I know I can just delete the pull request branch, pr-5737, and re-fetch it but that doesn’t seem like the ‘correct’ way to do things.</p>
  <h1>Answer:</h1>
  <p>Cherry-Picking from the excellent explanation/answer by torek. And taking the easy path based on my current practice. I was able to add new commits from upstream to the pull request branch, pr-5737.</p>
  <p>I used these commands:</p>
  <pre><code>$ git checkout master
  $ git branch -f pr-5737 FETCH_HEAD
  </code></pre>
  <p>I then pushed everything to my GitHub fork of the upstream project. Mainly for reasons of a backup. You will also see I have added two other pull-request branches I wanted.</p>
  <pre><code>$ git push  -v --all origin
  Pushing to git@github.com:username/fork-project.git
  Enter passphrase for key '/home/acct-name/.ssh/id_ecdsa':                                                                                                                   
  Counting objects: 68, done.                                                                                                                                             
  Delta compression using up to 4 threads.                                                                                                                                
  Compressing objects: 100% (68/68), done.                                                                                                                                
  Writing objects: 100% (68/68), 11.38 KiB | 0 bytes/s, done.                                                                                                             
  Total 68 (delta 50), reused 0 (delta 0)                                                                                                                                 
   remote: Resolving deltas: 100% (50/50), completed with 21 local objects.
  To git@github.com:username/fork-project.git                                                                                                                                
   = [up to date]      pr-5717 -&gt; pr-5717                                                                                                                                 
     ec0b073..67486dc  master -&gt; master                                                                                                                                   
     212c54a..e935946  pr-5737 -&gt; pr-5737                                                                                                                                 
   * [new branch]      pr-5763 -&gt; pr-5763                                                                                                                                 
  updating local tracking ref 'refs/remotes/origin/master'                                                                                                                
  updating local tracking ref 'refs/remotes/origin/pr-5717'                                                                                                               
  updating local tracking ref 'refs/remotes/origin/pr-5737'                                                                                                               
  updating local tracking ref 'refs/remotes/origin/pr-5763'
  $ git status
  On branch master
  Your branch is up-to-date with 'origin/master'.
  nothing to commit, working directory clean
  </code></pre>