From my comment:
Why don't you create two branches and add the two other versions to them and then work on the branches?
Which I think would agree with ctcherry's answer as well.
But if you really do want to create a completely different "branch" that is unrelated to master, then you can do it with git checkout --orphan
. The manual for git checkout describes to work of the option --orphan
:
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.
You might use it like this:
git checkout --orphan version2
git rm -rf .
<add version2 script>
git add your files
git commit -m 'Initial commit for version 2'
If your Git is older than 1.7.2 (when git checkout --orphan
was introduced), then you can use the alternate command sequence from “Creating New Empty Branches” in the Git Community Book:
Ocasionally, you may want to keep branches in your repository that do not share an ancestor with your normal code. Some examples of this might be generated documentation or something along those lines. If you want to create a new branch head that does not use your current codebase as a parent, you can create an empty branch like this:
git symbolic-ref HEAD refs/heads/newbranch
rm .git/index
git clean -fdx
<do work>
git add your files
git commit -m 'Initial commit'