How can I cleanup git working file set (like hg up -r null
)?
So only $proj/.git
hierarchy present and git st
don't show D
(deleted).
How can I cleanup git working file set (like hg up -r null
)?
So only $proj/.git
hierarchy present and git st
don't show D
(deleted).
After clarifications in your comments, it seems that you want to create a new root commit in your repository. There's a description of how to do this in the git community book.
First, make sure that the output of git status
is clean, so that you don't lose any of your previous work unintentionally. Then if you do the following:
git symbolic-ref HEAD refs/heads/newbranch
rm .git/index
git clean -fdx
git commit --allow-empty -m 'Initial empty commit'
Then you will be on a new branch called newbranch
, with a single root commit with an empty tree. If you then decide that you want this to be your new master branch, you can do:
git branch -m master oldmaster
git branch -m newbranch master
... which renames your old master
branch to oldmaster
, and then renames the new newbranch
branch to master
.
Alternative to what @Mark Longair mentioned, using git checkout --orphan
:
git checkout --orphan newbranch
git rm -rf .
git commit --allow-empty -m 'Initial empty commit'
Much more straightforward in my opinion