【问题标题】:Handle git submodules to make a "snapshot" of current state处理 git 子模块以制作当前状态的“快照”
【发布时间】: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 工具。
  • 这应该是一个答案,而不是一个评论,确实!

标签: git yocto


【解决方案1】:

对于这些东西,我更喜欢不同的工作流程。在 github 或您选择的服务上创建一个新的空存储库(例如 meta-openembedded)。

git clone <yourrepo>
cd meta-openembedded 
git remote rename origin upstream 
git remote add <yourgithubrepourl> 
git push
git checkout -b <myfeaturebranch> 

现在您有了 git 存储库 (fork) 的副本。根据您的需要进行修改,并为您想要的所有上游存储库重复此操作。您应该在您的功能分支上工作,您可以使用以下方式从原始分支中提取:

git pull <remote>

对于使用多个 git 存储库,我可以推荐 repo 工具。 repo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-14
    • 1970-01-01
    • 1970-01-01
    • 2020-10-21
    • 2021-04-10
    • 2014-09-21
    相关资源
    最近更新 更多