git 改变git结构
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9293089/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
changing the git structure
提问by Tausif Khan
I want to somehow change the git directory structure. Currently the architecture is like
我想以某种方式更改 git 目录结构。目前的架构就像
VL(repo) .git (hidden) code files ...... ..... I want it like html(repo) .git VL code files ...... ......
VL(repo) .git (hidden) code files ...... ..... I want it like html(repo) .git VL code files ...... ......
I had a solution to archive the current repo and then create the new repo with above structure. But the bad thing about this approach is that it removes all previous history. is there any better solution?
我有一个解决方案来存档当前存储库,然后创建具有上述结构的新存储库。但是这种方法的坏处是它删除了所有以前的历史记录。有没有更好的解决方案?
回答by eckes
Changing the name of the root folder from VL
to html
shall be no problem since git only works on the directories below that level.
将根文件夹的名称从 更改VL
为html
应该没有问题,因为 git 仅适用于该级别以下的目录。
So, what's left is introducing the folder VL
below the html
folder and move all code files
there:
所以,剩下的就是引入文件夹VL
下面的html
文件夹并将所有内容移到code files
那里:
mkdir VL
git mv <all your code> VL
git commit -m "moved all my code under VL"
Using git mv
you tell git that you moved things, so it could still keep track of the history.
使用git mv
你告诉 git 你移动了东西,所以它仍然可以跟踪历史。
Edit:
As Benjol notes in his comment, using git mv
is not neccessary. You could achieve the same by copying <all your code>
to VL
, then do
编辑:
正如 Benjol 在他的评论中指出的那样,使用git mv
不是必需的。您可以通过复制<all your code>
来实现相同的效果VL
,然后执行
git add VL
git rm <all your code>
git commit -m "moved all my code under VL
git add VL
git rm <all your code>
git commit -m "moved all my code under VL
git is smart enough to recognize the movement.
git 足够聪明,可以识别运动。
回答by Adam Dymitruk
Move your code manually. Then,
手动移动您的代码。然后,
git add -A
git commit -m "moved code"
Done.
完毕。