本文介绍了将子回购内容一起推送(不使用git子模块)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个主要的仓库中,还有另外一个仓库(可能是从github下载的),我称之为一个子仓库。



我不' t要使用git子模块功能。



子回购可能会被提交并推送到他自己的远程终端。但我想继续在主要的回购工作,忽略该文件夹(子回购)实际上是一个git回购。但我想跟踪主回购的子回购内容(我正在研究结果

我在这次努力中取得了成功,直到我推动主回购承诺,当我注意到sub-repo内容并没有推在一起。使用 git ls-files ,我看到了文件夹(sub-repo) )是存在的,但文件没有列出,所以我不确定sub-repo的内容是否可以通过main-repo进行跟踪。



使用 git ls-tree --full-tree -r HEAD ,我看到子回购被称为 commit ,而不是 blob 就像main-repo的其他文件一样。



是否可以推动子回购repo content together?

解决方案

我试过了,子回购中的文件可以和main-repo一起推送。以下步骤可以被引用:


  1. 本地main-repo中的Git bash
  2. 使用 git clone< URL for sub-repo> 克隆main-repo下的sub-repo
  3. 使用 git状态,你会发现未跟踪的文件夹子回购,然后使用 git add sub-repo / git commit 来跟踪

  4. / main-repo / sub-repo 中添加一个文件,例如new.txt。目录

  5. 使用 git add sub-repo / new.txt git commit note:它运行在 / main-repo 目录中)

  6. 使用 git push 推送到远程main-repo,你也可以在那里找到文件new.txt。您还可以使用 git ls-files 来查找文件

Note :您可能已经注意到,如果我们使用 git add sub-repo git commit ,如果我们使用 git add sub-repo / git commit ,模式为100644。 1600000是Gitlink,它表示您将提交记录为目录条目而不是子目录或文件,有点像子模块。 100644表示常规的不可执行文件。所以你可以把sub-repo作为一个文件夹。


Inside a main repo, there is another repo (which might have been downloaded from github, i.e.), I call this a sub-repo.

I don't want to use git submodules feature.

The sub-repo might be commited and pushed to his own remote eventually. But I would like to carry on work in the main repo, ignoring that folder (sub-repo) actually is a git repo. But I would like to track the sub-repo content from the main-repo (I was studying the consequences here).

I was successful in this endeavor until the point where I pushed main-repo commits, when I noticed the sub-repo content wasn't pushed together. Even though I added it when committing.

Using git ls-files, I see the folder (sub-repo) is there, but files aren't listed, so I'm not sure the sub-repo content is acctualy being tracked by main-repo.

Using git ls-tree --full-tree -r HEAD, I see the sub-repo being called a commit, instead of a blob as is the case for other files of the main-repo.

Is it possible to push the sub-repo content together?

解决方案

I tried and files in sub-repo can be pushed together with main-repo. The following steps can be refered:

  1. Git bash in local main-repo
  2. Use git clone <URL for sub-repo> to clone the sub-repo under main-repo
  3. Use git status, you will find a untracked folder sub-repo, then use git add sub-repo/ and git commit to track
  4. Add a file, such as new.txt in /main-repo/sub-repo directory
  5. Use git add sub-repo/new.txt and git commit (note: it’s run in the /main-repo directory)
  6. Use git push to push to remote main-repo, and you can find the file new.txt also there. Also you can use git ls-files to find the file

Note: You may have noticed that the mode is 160000 if we use git add sub-repo and git commit, and mode is 100644 if we use git add sub-repo/ and git commit. 1600000 is Gitlink, it means you record a commit as a directory entry rather than a subdirectory or a file, somewhat like submodules. 100644 means regular non-executable file. So you can treat sub-repo as a folder.

这篇关于将子回购内容一起推送(不使用git子模块)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 13:45