子模块的别名

时间:2015-12-15 23:57:34

标签: git bash github

我之前是否使用过SVN并且我一直在搜索,但我相信我们使用不同的子模块。至少当我们分支时。当我们分支时,我们希望子模块分支以及它们在其他应用程序中使用,所以我目前有两个简单的别名。

sclone = "!f()  { branch=${1}; git checkout -b $branch; git submodule foreach -q --recursive git checkout -b $branch; }; f"

switch = "!f()  { branch=${1-master}; git checkout $branch; git submodule foreach -q --recursive git checkout $branch; }; f"

那些工作正常但是提交和合并是绊脚石。我试图传递提交消息,但是对于每个子模块,我都看不到如何传递消息并保持返回状态。

所以半解决方案我最终传递了提交消息,但它需要对子模块提交进行vi编辑,这不是最佳的。我希望有一种方法仍然传递消息,但如果第一个返回0,则不会退出子模块上的foreach循环。但我无法看到所需的单引号,如果我用双引号转义那些OR不工作,它退出循环。

scommit = "!f() { git submodule foreach -q --recursive 'git commit -a || :' ; git commit -am \" $1 \";}; f"

第二个问题是合并,我真的需要在合并的分支中传递,如果没有子模块更改或者所有子模块都有变化,它就可以正常工作。

smerge = "!f()  { git merge $1; git submodule foreach -q --recursive git merge $1;}; f"

如果一个有着优秀git-fu的人可以指出我正确的方向或指出一个更好的方法将非常感激。基本上只是尝试使用自动执行子模块的单个别名(因为我们将其分支)所以不喜欢第三方解决方案。

目前也是推/拉别名,但这些工作正常。

spush = "!f()  { branch="$(git symbolic-ref head --short)"; git push origin $branch; git submodule foreach -q --recursive git push origin $branch; }; f"

spull = "!f()  { branch="$(git symbolic-ref head --short)"; git pull origin $branch; git submodule foreach -q --recursive git pull origin $branch; }; f"

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以将提交消息作为参数传递,这是我的解决方案,它需要手动目录路由:

soeput = "! msg=\"${1-Minor update}\" ; echo \"gput for [bimg, bx, bgfx, soe]\" ; cd F:/Git/soe/bimg ; sh -c 'git add -A && git commit -m \"$0\" && git push' \"$msg\"; cd ../bx ; sh -c 'git add -A && git commit -m \"$0\" && git push' \"$msg\"; cd ../bgfx && sh -c 'git add -A && git commit -m \"$0\" && git push' \"$msg\"; cd .. && sh -c 'git add -A && git commit -m \"$0\" && git push' \"$msg\""
相关问题