vidriduch
vidriduch

Reputation: 4863

hg update 00 and its git alternative

After creating new "master" repository in mercurial I used to always run

hg update 00

(it would only work with more one 0 ...)

This would remove all (tracked/committed) files and folders from repository folder but not the repository and only leave .hg folder. I've learn this from my colleague in previous job and used it ever since. I like the cleanliness about the folder and used it only for master repository which is not edited directly (only cloned).

What this command actually does and what is its alternative in GIT (if any)?

Thank you.

Upvotes: 2

Views: 551

Answers (2)

Ry4an Brase
Ry4an Brase

Reputation: 78350

You've asked two questions. @christophe-muller has the bigger one answered: "what is the git equivalent?

The other was "What [does] this command actually do?", and the answer to that is: It updates to the null revision. That's the revision before the first commit, which itself is revision zero. That's why hg update 0 doesn't work -- it takes you the first real commit. The null commit before that one has the hash/node-id of 000000000000000000000000, which you 00 matches, and the revision number -1.

The more traditional way to do this would be hg update null though hg update -1 works too.

Upvotes: 4

Christophe Muller
Christophe Muller

Reputation: 5110

There is a difference between hg and git in the way repositories look like on the server (what you call master repository): for mercurial it is similar to what you will clone on your machine: it has a .hg folder and can also have a working directory with files, which can be considered either useful sometimes or to be avoided.

For git on the other hand, you can have what they call a bare repository, having no working tree or no checked out copy of your files; in fact the git files are directly stored in the root folder of your repository instead of in a .git subfolder.

If this is what you want, preventing from having any files, then simply use:

git init --bare [directory]

Upvotes: 5

Related Questions