git - 子模块的别名

标签 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"

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

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

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

第二个问题是 merge ,我确实需要在 merge 的分支中传递这个问题,如果没有子模块更改或者所有子模块都有更改,它工作正常。

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

如果 git-fu 的人能给我指明正确的方向或指出更好的方法,我将不胜感激。基本上只是尝试使用一个别名来自动执行子模块(因为我们对它们进行了分支)所以不喜欢第三方解决方案。

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

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"

谢谢!

最佳答案

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

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\""

关于git - 子模块的别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34301698/

相关文章:

github - Github Enterprise 如何保护他们在虚拟机上交付的代码?

javascript - 从 atom Electron 中的 webview 访问 DOM

linux - 获取一个文件中不存在于另一个文件中的值

git - 无法在 ubuntu 虚拟机上安装 git

git - 在 ubuntu 20.04 上安装 git 时发生错误

git - 为什么我无法更改全局提交作者?

linux - 使用sed命令更改jail.conf中的内容时出现 puppet 错误?

bash - "echo exit |"中的 "echo exit | sqlplus user/pass@ora_instance @file.sql"的用途是什么?

Github 更新/覆盖发布的现有 Assets

Git 推送到 GitHub 失败 - 似乎正在尝试使用 HTTP?