超级项目中自动提交git子模块散列 [英] Auto-committing git submodule hash in super-project

查看:103
本文介绍了超级项目中自动提交git子模块散列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在git子模块中提交时,需要到超级项目中进行第二次提交,这是子模块的新哈希。



这是令人难以置信的烦人,容易忘记,如果你不这样做可能会导致各种问题。



我想要做的是:


  1. 在我的子模块中提交更改

  2. 在超级项目中自动提交散列

  3. 将子模块和超级项目都推送到它们的远程源('git push')

什么是最好的方法来弄清楚,如果你在一个子模块,超级项目等,并自动化这个?

也许某种post-commit钩子在子模块中?

解决方案

您是否尝试过混帐从?这正是它设计的目的。



您也可以自己编写脚本。请注意,git命令本身有两个选项可以帮助您: - work-tree - git-dir 。使用这些,您可以在不离开当前目录的情况下对任何回购进行操作。



然后还有 git submodule foreach --recursive git push


When you commit in a git submodule, you need to go up to the super-project to do a second commit, which is the new hash of the submodule.

This is incredibly annoying, easy to forget and can cause all manner of problems if you don't do it.

What I want to do is:

  1. Commit the changes in my submodule
  2. Have the hash committed automatically in the super-project
  3. Have both the submodule and the super-project pushed to their remote-origin ('git push')

What's the best way to figure out if you're in a submodule, where the super-project is, etc and automate this?

Maybe some kind of post-commit hook in the submodule?

解决方案

Have you tried git-slave? This is exactly what it's designed to do.

You can also script that yourself. Be aware that there are 2 options on the git command itself that can help greatily: --work-tree and --git-dir. Using these you can act on any repo without leaving the current directory.

Then there is also git submodule foreach --recursive git push.

这篇关于超级项目中自动提交git子模块散列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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