在Mercurial中更改目录结构 [英] Changing a directory structure in Mercurial
问题描述
我有一个单人单资料库.目录结构很简单:
I have a single-person single-folder mercurial repository. The directory structure is simple:
P104
lecture_notes
files under version control live here
过了一会儿,我意识到我想在存储库中有两个目录,像这样
After a while I realize I want to have two directories within the repository, like this
P104
lecture_notes
files under version control live here (.hg is here)
homework
more files under version control
现在,如果我只是想将文件添加到存储库中,它将失败:
Now, if I'm just trying to add files to the repository, it fails:
br@ymir:~/P104/lecture_notes$ ll ..
total 16
drwxr-xr-x 4 br br 4096 2012-02-02 18:05 ./
drwxr-xr-x 4 br br 4096 2012-02-01 20:46 ../
drwxr-xr-x 2 br br 4096 2012-02-02 17:44 homework/
drwxr-xr-x 4 br br 4096 2012-02-02 18:06 lecture_notes/
br@ymir:~/P104/lecture_notes$ hg add ../homework/hw1_P104.tex
abort: ../homework/hw1_P104.tex not under root
我的第一个想法是在目录结构中将存储库向上一级克隆,将文件添加到克隆中,然后删除原始存储库.但是,即使克隆失败:
My first idea was to clone the repo one level up in the directory structure, add files to the clone, and delete the original repo. But even cloning fails:
br@ymir:~/P104/2011/lecture_notes$ hg clone . ..
abort: destination '..' is not empty
所以问题是,除了在其他地方创建干净的存储库并手动复制文件之外,是否还有其他类似Mercurial的方法?
So the question is whether there's a Mercurial-ish way of doing this other than creating a clean repository somewhere else and copying files manually?
推荐答案
如果您的Mercurial存储库的根目录位于~/P104/lecture_notes
下,我宁愿:
If the root directory of your Mercurial repo is under ~/P104/lecture_notes
, I would rather:
- 将
lecture_notes
重命名为P104 - 创建一个子目录
lecture_notes
- 移动该新子目录中的所有现有文件
- 在已重命名的P104目录中添加
homework
及其文件 -
hg add
一切
- rename
lecture_notes
into P104 - make a subdirectory
lecture_notes
- move all the existing files in that new sub-directory
- add
homework
and its files in the renamed P104 directory hg add
everything
此想法是将.hg
存储库保留在原位置(~/P104/lecture_notes
重命名为~/P104/P104
),并重新组织该重命名目录中的文件.
无需克隆.
The 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.
这篇关于在Mercurial中更改目录结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!