I want to create a branch out of master but I need this branch to have an empty tree. After a bit of researching I've come up with the following situation:
- Master branch have a single commit with a dummy file.
- I checkout a new branch
- I remove all files and commit
- I create a new commit with --allow-empty
The following commands should get you up to that:
$ git init
$ touch dummy
$ git add .
$ git commit -m 'initial commit'
$ git checkout -b new-branch
$ git rm -rf .
$ git commit -m 'clean up tree'
$ git commit --allow-empty -m 'new branch initial commit'
Now I want to get rid of 'clean up tree' commit. I'm trying to use rebase --onto like
$ git rebase --onto HEAD~2 HEAD^
But I end up with a single commit ('initial commit') and all refs on it (HEAD, master, new-branch). And if I checkout into new-branch, dummy file is back.
Where did my 'new branch initial commit' went? What I'm a missing?
Obs.: I'm doing this because I want to relate those branches but I don't want to keep the files from the parent commit.