强制Git子模块始终保持最新状态 [英] Force Git submodules to always stay current

查看:523
本文介绍了强制Git子模块始终保持最新状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢git submodules。另外,我讨厌git submodules。我喜欢他们的是它如何让你清楚地划分依赖关系等等。我明白了让他们指向具体的回购交易,我确实需要。但在我的情况下,我正在建立一个库,将用于另一个项目,所以我想保持它在单独的回购。



然而,烦恼来当我每天在这个库上工作时,我总是不得不使用我的库切换回应用程序来提交指针更新。



所以,是吗?

解决方案可能有一个git子模块总是在它指向的repo的头部,而我经常更新并添加到这个库中?不,这是设计。如果有一种方法将子模块指向某个其他存储库的当前头,则无法从主存储库检索历史版本(例如标记版本)。它不知道要检出哪个版本的子模块。



话虽如此,您可能对 git subtree 脚本。这提供了一种可能与您的工作流程更加兼容的子模块的不同工作方式。我刚刚在最近的在HN上的帖子中提醒过这一点。


I love git submodules. Also, I hate git submodules. What I love about them is how it enables to you to cleanly compartmentalize dependencies etc. I get the point of having them point to a specific commit on a repo, I do. But in my case, I'm building a library that will be used in another project, so I want to keep it in that seperate repo.

However, the annoyance comes when I'm working on a daily basis on this library and I constantly have to switch back to the app using my library to commit the pointer update.

So, is it possible to have a git submodule just always be on the head of the repo it's pointing at while I'm constantly updating and adding to this library?

解决方案

No, and this is by design. If there were a way to point a submodule to the "current head" of some other repository, then it would be impossible to retrieve a historical version (such as a tagged version) from the main repository. It wouldn't know which version of the submodule to check out.

Having said that, you may be interested in the git subtree script. This offers a different way of working with submodules that may be more compatible with your workflow. I was just reminded of this by the recent post on HN.

这篇关于强制Git子模块始终保持最新状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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