繁体   English   中英

git:显示当前合并配置值

[英]git: display current merge config value

有没有一种方法可以显示git中的当前merge config选项, 而无需手动指定我所在的当前分支。我想做这样的事情:

$ git cur-merge-val
branch.current.merge = /refs/heads/current

git cur-merge-val可能是一系列冗长而复杂的git命令,我可以为其添加别名-只要我在命令行上亲自键入的内容不需要键入我所在的当前分支(因为这似乎是多余的,因为该信息应以某种方式在程序上可访问)。

创建以下脚本(例如,将其cur-merge-val.sh并使其可执行):

current=`git status -s -b | head -1 | cut -d' ' -f2`
git config branch.$current.merge

然后,只需将以下内容添加到您的.gitconfig文件中:

[别名]
cur-merge-val = /路径/到/cur-merge-val.sh

我找到了一种解决方案:

  1. 避免使用瓷器命令,而使用管道命令
  2. 还显示当前的远程配置值和所有可能的合并配置值(如果有多个)。
  3. 避免制作另一个可执行文件

请参阅https://stackoverflow.com/a/1593487/10608 ,以获取有关为什么以这种方式获取当前分支名称的参考。

[alias]
    cur-merge-val = !branch_name="$(git symbolic-ref HEAD)" && branch_name=${branch_name##refs/heads/} && git config --get-all branch.$branch_name.remote; git config --get-all branch.$branch_name.merge

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM