How to completely clear the git working directory?

In mercurial, I used to do hg up 00to completely clear the working directory.

Resets the working directory to it immediately after execution hg init.

Is there any equivalent in git?

Note that it hg up 00does not match the hg up 0one that is upgraded to the first version; instead, it is equivalent hg up null, for only a couple of characters shorter to enter. * 8' )

Also note that I do not want to just do rm -rf *git in the root directory of the working directory, since then it git statuswill show all files as deleted. I just want to update the repository to the state before the first commit. Alas, my internet searches and git guides did not provide me with the information I need to develop how to do this git.

As a background, I want to leave the repository in place so that I can easily check for another commit later. One of the reasons I want to do this is because I have a very large repository (actually it’s git svn repo) and I don’t want me to have to repeat it again (it took several days to finish, and you aren supposed to clone gitsvn repo). I really want to free up the space occupied by the working copy when I do not need it.

+3
source share
3 answers

The equivalent of version zero is called the open repository in git.  This search provides a rough overview of the topic, here you can find various ways to convert non-bare naked repos here .

hg, - . , - , git, . . git 2 .

+2

, , git , . "" "reset" git.

reset "", .

git updated-ref -d "$(git symbolic-ref HEAD)"

, .

( , ).

git rm -r --cached .

-f, .

, . : .

git clean -fd # WARNING, dangerous
+2

These are the solutions that come to my mind:

1- You can remove the .git directory from your working directory and there will be no git repository in your working directory.

2- You can reset the initial commit (the initial commit will remain anyway) by issuing:

git reset --hard `git rev-list HEAD | tail -n 1`
+1
source

Source: https://habr.com/ru/post/1785424/


All Articles