Git: Two initial commits
You need to create an orphan branch:
git checkout --orphan <branch>
git checkout
has an option for exactly such use case: --orphan
.
From the Git manual:
--orphan <new_branch>
Create a new orphan branch, named
<new_branch>
, started from<start_point>
and switch to it. The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits.
Also, the man says explicitly:
If you want to start a disconnected history that records a set of paths that is totally different from the one of
<start_point>
, then you should clear the index and the working tree right after creating the orphan branch by running "git rm -rf .
" from the top level of the working tree.
Apart from using the checkout --orphan
method, you can as well create a separate repository in your other code base, make the initial commit, and then push to the other repository (or from the other repository pull from this one)
cd old-code
git init
git add .
git commit -m 'Initial commit of historical codebase'
git push ../path/to/current/code/repository master:historical
After that you can remove the repository again (rm -rf old-code/.git
) if you don't need it (but it shouldn't hurt)