如何在父git项目中使用git存储库? [英] How can I use a git repository in my parent git project?

查看:100
本文介绍了如何在父git项目中使用git存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用子模块将github仓库中的副本保留在我的第3方目录中.创建并获取文件后,当我从项目提交时,它只会看到该文件夹​​,没有文件(是的,文件在那里).

I tried using submodules to keep a copy from github repository inside my 3rd party directory. After creating and fetching the files, when I commit from project it only see the folder, no the files (and yes, the files are there).

有特定的命令吗?

推荐答案

在GitHub上,您只会看到 灰色文件夹 :它是索引中的 gitlink特殊条目,记录了所述子模块的SHA1.

On GitHub, you will only see a gray folder: it is the gitlink special entry in the index, recording the SHA1 of said submodule.

在您的本地克隆上,只要您执行

On your local clone, as long as you do a

git submodule update --init

您将看到子模块的全部内容.

You will see the full content of the submodule.

但是当您推动时,您必须从以下位置推动:

But when you push, yuo must push from:

  • 子模块文件夹,以便子模块上游存储库记录您的新提交
  • 回到父存储库(cd ..),添加,提交并推送新的gitlink状态(该记录将记录子模块的新SHA1):这就是在您更新GitHub存储库中的灰色文件夹"时从本地克隆中推送.
  • the submodule folder, in order for the submodule upstream repo to record your new commit
  • go back to the parent repo (cd ..), add, commit and push the new gitlink state (which records the new SHA1 of your submodule): that is what updates the "gray folder" in your GitHub repo when you push from your local clone.

这篇关于如何在父git项目中使用git存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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