title: How to move some parts of a project into Git branches without losing their history?
body: <p>I started my main project with CVS in 2006, I moved to Subversion in 2008 and I moved to Git in 2021 but at the very beginning, I was a newbie in version control and <a href="https://sourceforge.net/p/tuer/git/ci/master/tree/" rel="nofollow noreferrer">my repository</a> is messy, several distinct implementations of my game.</p>
  <p>I would like to move them into separate branches but I don't want to lose the history between branches, i.e I would like to be able to find in the log that some files were initially in the &quot;master&quot; branch but were moved into the &quot;pre-alpha&quot; branch. How can I achieve that? Should I create a branch, switch to it, remove the files that have nothing to do in it, go back to the &quot;master&quot; branch and remove the files already in the new branch? Is it the proper way of using Git for this purpose?</p>
  <p>P.S: I did this based on larsks' answer:</p>
  <pre><code>git subtree split -b prealpha --prefix trunk
  git subtree split -b alpha --prefix alpha
  git subtree split -b jme --prefix tuer
  git push origin prealpha
  git push origin alpha
  git push origin jme
  git subtree split -b prebeta --prefix pre_beta
  git branch -m master oldmaster
  git branch -m prebeta master
  git push origin oldmaster
  </code></pre>
  <p>Only this last line doesn't work:</p>
  <pre><code>git push origin master
  </code></pre>
  <blockquote>
  <p>! [rejected]        master -&gt; master (non-fast-forward) error:
  impossible to push the references to
  'https://gouessej@git.code.sf.net/p/tuer/git'</p>
  </blockquote>