I have a single-person single-folder mercurial repository. The directory structure is simple:
P104
lecture_notes
files under version control live here
If the root directory of your Mercurial repo is under ~/P104/lecture_notes
, I would rather:
lecture_notes
into P104lecture_notes
homework
and its files in the renamed P104 directoryhg add
everythingThe idea is to keep the .hg
repo where it is (~/P104/lecture_notes
renamed into ~/P104/P104
) and reorganize the files within that renamed directory.
No need to clone.
I like VonC's solution where you don't move the .hg
folder. It's a straight forward solution. Here is an alternative where you do move it and so have to rename fewer folders:
Move the .hg
folder up to ~/P104
$ mv ~/P104/lecture_notes/.hg ~/P104
Seen from the perspective of Mercurial, you will have moved all the top-level files into a lecture_notes
directory. There will also suddenly be new untracked files in the homework
folder.
Let Mercurial figure out the renames:
$ hg addremove
This will correctly detect that files that were top-level files before now live in the lecture_notes
directory. The untracked (and un-ignored) files in homework
are just added.
Save the changes:
$ hg commit
The overall "trick" is that files in the working copy are seen relative to the .hg
directory. So by moving the .hg
directory up in the file system hierarchy, we effectively move the working copy files down in the hierarchy inside the working copy.