[英]git: display current merge config value
Is there a way to display the current merge config option in git without manually specifying the current branch I am in. I am wanting to do something like this: 有没有一种方法可以显示git中的当前merge config选项, 而无需手动指定我所在的当前分支。我想做这样的事情:
$ git cur-merge-val
branch.current.merge = /refs/heads/current
where git cur-merge-val
could be some long, complicated series of git commands to which I can make an alias for -- so long as what I personally type on the command line doesn't require typing the current branch I'm in (because that seems redundant since that information should be programmatically accesible somehow). git cur-merge-val
可能是一系列冗长而复杂的git命令,我可以为其添加别名-只要我在命令行上亲自键入的内容不需要键入我所在的当前分支(因为这似乎是多余的,因为该信息应以某种方式在程序上可访问)。
Create the following script (eg, call it cur-merge-val.sh
and make it executable): 创建以下脚本(例如,将其
cur-merge-val.sh
并使其可执行):
current=`git status -s -b | head -1 | cut -d' ' -f2`
git config branch.$current.merge
Then, just add the following to your .gitconfig file: 然后,只需将以下内容添加到您的.gitconfig文件中:
[alias]
[别名]
cur-merge-val = /path/to/cur-merge-val.shcur-merge-val = /路径/到/cur-merge-val.sh
I found a solution which: 我找到了一种解决方案:
see https://stackoverflow.com/a/1593487/10608 for a reference of why I get current branch name the way I do. 请参阅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.