超级项目中自动提交git子模块散列 [英] Auto-committing git submodule hash in super-project
问题描述
在git子模块中提交时,需要到超级项目中进行第二次提交,这是子模块的新哈希。
这是令人难以置信的烦人,容易忘记,如果你不这样做可能会导致各种问题。
我想要做的是:
- 在我的子模块中提交更改
- 在超级项目中自动提交散列
- 将子模块和超级项目都推送到它们的远程源('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:
- Commit the changes in my submodule
- Have the hash committed automatically in the super-project
- 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屋!