Git:将本地git子模块(包括子模块文件)推送到远程裸仓库 [英] Git: Push a local git submodule, including submodule files, to a remote bare repository

查看:1064
本文介绍了Git:将本地git子模块(包括子模块文件)推送到远程裸仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个用git管理的本地项目,一个依赖于另一个,例如:

I have two local projects which I manage with git, one being dependent on the other – like this:

project A/
├── project B/     
│   ├── file B₁
│   ├── file B₂
│   ├── …

project B作为project A的git子模块对我来说很有意义.

It makes sense to me to have project B as a git submodule of project A.

现在,我已经为project A建立了一个远程 bare 存储库,用于备份和共享.当然,我希望远程存储库包含所有project B,包括其文件(file B₁file B₂,...).但是git pushgit push --recurse-submodules=on-demand达不到这个目的.每当我按git ls-tree -r HEAD列出远程存储库中的文件时,仅列出project A本身的文件.这对我来说很有意义.

Now, I have set up a remote bare repository for project A for backup and sharing purposes. Of course, I want the remote repository to contain all of project B, including its files (file B₁, file B₂, …). But git push and git push --recurse-submodules=on-demand don’t achieve this. Whenever I list the files in my remote repository by git ls-tree -r HEAD, only the files of project A itself are listed. This does make sense to me.

但是,有没有办法将整个子模块project B以某种方式(最好以一种干净的方式)推送到我的远程基础存储库中?

However, is there a way to push the entire submodule project B to my remote base repository somehow, preferably in a clean way?

推荐答案

如果B实际上是子模块,则应该有一个引用它的.gitmodule.
在该.gitmodule文件中,您将看到将B推送到的远程仓库URL,以防B中有任何新的提交.

If B is actually a submodule, you should have a .gitmodule referencing it.
In that .gitmodule file, you would see the remote repo URL where B is pushed, in case there is any new commits done in B.

但是B是子模块,意味着A中将没有B文件,而仅是B SHA1的引用.

But B being a submodule means A won't have B files in it, only a reference to B SHA1.

如果需要,可以取消子模块B(使用我的答案

If you want, you can un-submodule B (with my answer or this one) in order to keep all the B files in A.

这篇关于Git:将本地git子模块(包括子模块文件)推送到远程裸仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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