移动.git目录 [英] Moving a .git Directory

查看:109
本文介绍了移动.git目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个早期在项目学习曲线中创建的存储库。正如我学到的更多,我意识到这是创建问题,因为我想跟踪的一些文件在编译的源代码中不需要。我想要做的是创建一个新的项目父目录,将现有的源目录移入该父目录,并将不需要编译的文件迁移到该父目录中。

I have a repository that I created early in the learning curve of a project. As I've learned more, I've realized that this is creating problems because some of the files I want tracked aren't required in the compiled source. What I'd like to do is create a new "project" parent directory, move the existing source directory into that parent directory and the migrate the files that don't need to be compiled into that parent directory.

git可以吗?我是否会将 .git / 目录移至父级别,以彻底销毁所有引用?

Is that possible with git? Will I completely destroy all of the references since I'll want to move the .git/ directory up to the parent level as well?

感谢。

推荐答案

一种选择是在当前资源库中移动内容。

One option would be to just move things around within your current repository.

例如,假设类似于:

/.git
/lib/lib.c
/lib/lib.h
/test.c
/readme.txt

您可以创建一个新文件夹(下面的src),并将lib文件夹和test.c文件夹移动到新文件夹中(使用git mv)。然后,当前目录将成为您所需的项目父目录,并且所有代码都将位于新文件夹中。

You could create a new folder (src below) and move the lib folder and the test.c folder into the new one (using git mv). Then the current directory will be your "project" parent directory that you want, and all the code will be in the new folder.

/.git
/src/lib/lib.c
/src/lib/lib.h
/src/test.c
/readme.txt

VonC在评论中指出,另一种方法是git filter-branch。使用这个我相信你可以建立一个重组版本库,这个版本不会为这些动作提交提交,这些文件只会存在于新的结构中。

An alternative would be git filter-branch, as pointed out by VonC in the comments. Using that I believe you could build a restructured repository that would not have a commit for the moves, the files would just always have existed in the new structure.

这篇关于移动.git目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆