如何将google-chrome设置为git默认浏览器 [英] how to set google-chrome as git default browser

查看:573
本文介绍了如何将google-chrome设置为git默认浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,我希望 GIT 在Chrome浏览器中打开帮助页面,但Windows 7默认浏览器是IE浏览器,我无法更改其他原因。

  [web] 
browser = chrome
[浏览器chrome]
cmd = C:/ Program Files(x86)/Google/Chrome/Application/chrome.exe
path = C:/ Program Files(x86)/ Google / Chrome / Application /

但它仍然会打开IE浏览器。在git的bash环境中,它给出消息启动默认浏览器以显示HTML ...。在Git Gui上,它会抛出更长的消息。

 浏览器chrome不可用作'C:/ Program Files(x86)/谷歌/铬/应用/。 
浏览器chrome不可用作'C:/ Program Files(x86)/ Google / Chrome / Application /'。
执行
exec {C:/ Program Files(x86)/Git/bin/sh.exe} {C:/ Program Files(x86)/ Git / libexec / git-core / git-
(evalbody line 1)
从$ b $中调用
(evalbody line 1)
beval exec $ opt $ cmdp $ args
(程序git第23行)

gitweb中调用 - 浏览$ url
程序start_browser第2行)

中调用start_browser {file:C:/ Program Files(x86)/Git/doc/git/html/index.html}
菜单调用)

有人可以帮我解决这个问题吗?

编辑:也尝试过

  [web] 
browser = chrome
[browserchrome]
path = C:/ Program Files(x86)/Google/Chrome/Application/chrome.exe

现在我可以从Git Gui打开在线文档了。但它在git bash中不起作用。

解决方案

Git期望配置设置浏览器。<工具> .path 指向已识别浏览器的可执行文件,而不是包含目录。 浏览器。< tool> .cmd 仅在您指定的浏览器不在已识别的浏览器(其中chrome为一个)的列表中时使用。请参阅 git-web - 浏览 docs for details。



尝试在 .gitconfig 中使用它:

  [web] 
browser = chrome
[browserchrome]
path = C:/ Program Files (x86)/Google/Chrome/Application/chrome.exe

如果您想自定义命令行这是用来启动Chrome的,你可以给它一个不是被识别为支持的浏览器的名称,而是在 cmd 中指定命令:

  [web] 
浏览器=特殊浏览器
[浏览器特殊浏览器]
cmd = C:/ Program Files(x86)/Google/Chrome/Application/chrome.exe --new-window


I want GIT to open the help pages in Chrome browser by default though the Windows 7 default browser is IE which I can't change for other reasons. I have added the following to the git config file.

[web]
    browser = chrome
[browser "chrome"]
    cmd = C:/Program Files (x86)/Google/Chrome/Application/chrome.exe
    path = C:/Program Files (x86)/Google/Chrome/Application/

But it still opens IE browser. In git's bash environment it gives the message "Launching default browser to display HTML ...". On Git Gui, it throws a lengthier message

The browser chrome is not available as 'C:/Program Files (x86)/Google/Chrome/Application/'.
The browser chrome is not available as 'C:/Program Files (x86)/Google/Chrome/Application/'.
    while executing
"exec {C:/Program Files (x86)/Git/bin/sh.exe} {C:/Program Files (x86)/Git/libexec/git-core/git-web--browse} {file:C:/Program Files (x86)/Git/doc/git/ht..."
    ("eval" body line 1)
    invoked from within
"eval exec $opt $cmdp $args"
    (procedure "git" line 23)
    invoked from within
"git "web--browse" $url"
    (procedure "start_browser" line 2)
    invoked from within
"start_browser {file:C:/Program Files (x86)/Git/doc/git/html/index.html}"
    (menu invoke)

Could someone help me resolve this?

EDIT: Also tried

[web]
    browser = chrome
[browser "chrome"]
    path = C:/Program Files (x86)/Google/Chrome/Application/chrome.exe

Now I am able to open online documentation in chrome from Git Gui. But it does not work in git bash.

解决方案

Git is expecting the config setting browser.<tool>.path to point to the executable of a recognized browser, not the containing directory. browser.<tool>.cmd is only used if the browser you specify isn't on the list of recognized browsers (of which "chrome" is one). See the git-web--browse docs for details.

Try using this in your .gitconfig instead:

[web]
    browser = chrome
[browser "chrome"]
    path = C:/Program Files (x86)/Google/Chrome/Application/chrome.exe

If you want to customize the command line that's used to launch Chrome, you can give it a name that isn't recognized as a supported browser, and specify the command in cmd instead:

[web]
    browser = specialchrome
[browser "specialchrome"]
    cmd = C:/Program Files (x86)/Google/Chrome/Application/chrome.exe --new-window

这篇关于如何将google-chrome设置为git默认浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆