Reputation: 2231
very new in Mercurial. I have noticed that my hg init is not working. let me explain it:
when I give this command hg clone https://www.mercurial-scm.org/repo/hello my-hello ,then, my_hello folder is created with all the(2) files. then I delete .hg folder from my_hello. then I initialize this folder with hg init. it is initialized.
But after initializing that, when I go to clone the folder with hg clone my_hello new_my_hello, it just make the .hg folder in the new_my_hello folder, not the other files it should.
and for all the tries I am getting this problem. please help.
I am using windows 7 64 bit. My Mercurial is also 64 bit.
Upvotes: 1
Views: 943
Reputation: 2260
Short answer: untracked files are not included in a clone.
If you first remove the .hg metadata directory and reinitialize a new one, it will no longer track any files; no files are added by default on init. So when you clone it, you get a clone of an empty repository. Like so:
$ hg clone https://www.mercurial-scm.org/repo/hello my-hello
requesting all changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd my-hello
$ ls
Makefile hello.c
$ hg st --all
C Makefile
C hello.c
Above is a perfectly normal copy of the repo with no modified files.
$ rm -rf .hg
$ hg st --all
abort: There is no Mercurial repository here (.hg not found)!
Now there is no repo any more.
$ hg init
$ hg st --all
? Makefile
? hello.c
Now there is one, but it no longer tracks the files, hence the "?".
$ hg clone . ../new-my-hello
updating to branch default
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd ../new-my-hello
$ hg st --all
$ ls
The clone does not include untracked files, so the two "?-files" from "my-hello" are not cloned.
Upvotes: 4
Reputation: 678
You create a repository by running hg init
, which you've already done. However, you have not yet started tracking any files. To do this, you must explicitly tell hg which files to track with hg add file1 file2 ...
. Alternately, you can add all files by calling hg addremove
. After this, you need to add those files to the repo via hg commit
.
Once you do this in the original repo, in your new_my_hello, you will be able to pull these changes from my_hello by calling hg pull
, and in order to get the latest versions of those files, follow with an hg update
.
All that being said, I am certain that no good can come from deleting your existing .hg folder.
A very helpful resource for learning hg workflows that does a better job of explaining why you weren't getting what you thought you were getting is http://hginit.com
Upvotes: 3