本文介绍了在目录中创建一个新的git仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Git仓库中,我有一个目录A.在分支中,我在A下创建了一个目录B.有没有办法在目录B中创建/初始化一个新的Git仓库?如果要复制该目录,清除所有.git数据,并在该新复制的目录中执行git init,那么这个技巧是否有用?请注意,您可以拆分一个git repo,使用git filter-branch在自己的repo中创建一个子目录。

请参阅

(和。


In my Git repo, I have a directory A. In a branch, I've created a directory B under A. Is there a way to create/initialize a new Git repo in directory B? Would copying that directory, clearing all of the .git data, and do a git init in that new copied directory do the trick?

解决方案

Note that you can split a git repo, making a subdirectory in its own repo with git filter-branch.

See "How can I split a repository apart into smaller atomic repositories?"
(and "Detach subdirectory into separate Git repository":

   git filter-branch --subdirectory-filter foodir -- --all

That would allow you keep the history, but will rewrite the one of your original repo (meaning other contributors would have to reset their clone to your new history).

Once done, you can clone that new repo right where your subdirectory were: nested repos are ignored by the parent repo.
Or you can include that sub-repo as a submodule.

这篇关于在目录中创建一个新的git仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 01:36