【发布时间】:2020-05-17 10:49:37
【问题描述】:
我有一个 Yocto 项目,其中一些文件夹是 git 存储库的克隆。
现在我需要为当前layers 目录的“快照”创建一个存储库。
示例:
layers/
.git // <--- my new repository
meta-openembedded/ // <--- it's a repo
.git
meta-qt5/ // <--- it's a repo
.git
在我的“层”存储库中,我不想将“子模块”维护为 git 存储库。这是因为我更改了一些文件,但我不确定是否可以提交它们(这些存储库当然不是我的!)。
我尝试在.gitignore 中添加.git/,但它仍然将目录视为子模块并且不会将它们添加到我的存储库中:
$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .gitignore
new file: meta-openembedded
new file: meta-qt5
...
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: meta-openembedded (modified content)
modified: meta-qt5 (modified content)
添加目录不起作用(顺便说一句,它们已经存在)。
当然,粗鲁的方法是删除.git 目录...但我希望有一种方法可以告诉 git 忽略它们。
无论如何,我也尝试将我的更改提交到其中一个子模块,但它仍然不会添加它:
Changes not staged for commit:
modified: meta-openembedded (new commits)
【问题讨论】:
-
你做错了,编辑上游层可能不是一个好主意。只需为 meta-obenembedded、meta-qt 创建一个新的存储库并更改 git 远程。
-
@FlorianBerndl,如果我理解正确,我需要删除
.git目录,而不是发布一些git init来创建新的存储库?然后删除 git 目录并依赖我的顶级仓库就足够了。 -
1.) 转到 github 2.) 创建新的 EMPTY 存储库 meta-openembedded 3.) cd meta-openembedded 4.) git remote rename origin upstream 5.) git remote add
6. ) 混帐推。现在你有了一个 git repo (fork) 的副本。根据需要进行修改,并对所有上游回购重复此操作。对于使用多个 git 存储库,我可以推荐 repo 工具。 -
这应该是一个答案,而不是一个评论,确实!