title: git: Merge Branches but Keep Commit History
body: <p>In my git workflow we have one main repository and one branch, master. Everyone pulls from remote master and everyone pushes to remote master. I want to work in my own branch while I prepare a feature. So far my history is something like this:</p>
  
  <pre><code>git pull --rebase
  git checkout -b new_feature
  &lt;make some commits&gt;
  git checkout master
  git pull --rebase
  </code></pre>
  
  <p>Now I want to merge the branch and here's what I need:</p>
  
  <ol>
  <li>No merge commits in my local master branch.</li>
  <li>All commits made into my new_feature branch merged into master as if I had made them in master.</li>
  <li>All merged commits to be merged somewhere on top of my local remote head pointer.</li>
  </ol>
  
  <p>My biggest concern is item 3, when is needed so that I can safely push the changes. If the merged commits are intertwined with commits before head then I will have problems pushing, see related problem I had: <a href="https://stackoverflow.com/questions/27785582/git-pushing-single-commits-reordering-with-rebase-duplicate-commits">git: Pushing Single Commits, Reordering with rebase, Duplicate Commits</a>.</p>
  
  <p>I've read the following:</p>
  
  <ul>
  <li><a href="http://mettadore.com/2011/05/06/a-simple-git-rebase-workflow-explained/" rel="noreferrer">http://mettadore.com/2011/05/06/a-simple-git-rebase-workflow-explained/</a></li>
  <li><a href="https://stackoverflow.com/questions/28407020/keep-commits-history-after-a-git-merge">Keep commits history after a &#39;git merge&#39;</a></li>
  <li><a href="https://stackoverflow.com/questions/7297379/how-do-you-rebase-the-current-branchs-changes-on-top-of-changes-being-merged-in">How do you rebase the current branch&#39;s changes on top of changes being merged in?</a></li>
  </ul>
  
  <p>And I think I need to do:</p>
  
  <pre><code>git checkout master
  git pull --rebase
  git checkout new_feature
  git rebase master
  git checkout master
  git rebase new_feature
  git push
  </code></pre>
  
  <p>My understanding is that </p>
  
  <pre><code>git checkout new_feature
  git rebase master
  </code></pre>
  
  <p>will make new_feature appear as if it was branched off from the new current head. Is that true? And that </p>
  
  <pre><code>git checkout master
  git rebase new_feature
  </code></pre>
  
  <p>will place new_feature on top of master. Is that correct? If so, this is the main point of my confusion. If "git rebase master" places master commits at the bottom of new_feature, then why does "git rebase new_feature" place new_feature commits at the top of master, i.e. why doesn't it do the opposite?</p>