使用Git处理多个相互依赖的项目(Working on multiple interdependent projects with Git)

编程入门 行业动态 更新时间:2024-10-20 07:53:57
使用Git处理多个相互依赖的项目(Working on multiple interdependent projects with Git)

我的问题如下:

我正在开发2个Python包A和B,B使用A.因此,当我在包A中更改某些内容时,我经常需要对包B进行一些小的更改以适应函数调用等。

我的包都是git存储库。 我希望能够在一次提交中提交来自两个repos的更改。 但是,我希望保持在每个仓库中单独提交的能力。

我检查了git子模块和git worktree,但它似乎不是我需要的。 你知道其他一些方法吗?

谢谢。

My problem is the following:

I am developing 2 Python packages A and B and B uses A. Thus, when I change something in the package A, I often have to make some small changes in package B to adapt function calls etc.

Both my packages are git repositories. I would like to be able to commit changes from both repos in a single commit. However, I want to keep the ability to commit separately in each repo.

I checked git submodules and git worktree but it doesn't seem to be exactly what I need. Do you know some other method?

Thanks.

最满意答案

我不认为这是可能的。 提交基本上是生成在对象数据库中的文件集合,提交本身保存在同一个数据库中,该数据库位于.git/ 。 因此,一个存储库中的一个提交不能包含另一个存储库中的文件,因此您无法一次提交多个存储库。

如果您觉得需要在单个提交中更改两个存储库,可能它们应该合并到一个存储库中(我知道可能有理由不这样做)。 或许你应该重温一个人与另一个人融合的方式,这样一个人的变化并不会总是引发另一个人的变化。 最终,听起来你正在尝试使用错误的工具来完成工作。

I don't think this is possible. A commit is basically a collection of files that live in the objects database, and the commit itself is persisted in that same database, which is located inside of .git/. Therefore, one commit from one repository can't contain files from another, so you can't commit to multiple repositories at once.

If you feel the need to change both repositories in a single commit, maybe they should be merged into a single repository (I understand there might be reasons not to do so). Or maybe you should revisit the way one integrates with the other so that a change in one doesn't always trigger a change in the other. Ultimately, it sounds like you're trying to use the wrong tool for the job.

更多推荐

本文发布于:2023-08-06 19:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1455724.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   相互依赖   项目   Git   projects

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!