5

I was using Git on a Windows box and the git bash always used the web version for help. I really liked this and I am trying to do the same on my mac.

I ran:

$ git config --global help.format web
$ git config --global web.browser firefox

and the output of a help command is:

$ The browser firefox is not available as 'firefox'.

I then set:

$ git config --global browser.firefox.path /Applications/Firefox.app/Contents/MacOS/firefox-bin

Since I usually have firefox open, it now cries:

A copy of Firefox is already open. Only one copy of Firefox can be open at a time.

The real command I would like git to use is open -a Firefox.app somefile. I tried setting browser.firefox.cmd with no avail.

My question: how can I configure git to use the web version and call/use firefox in a way that won't cause issue if it's already open?

Paŭlo Ebermann
  • 73,284
  • 20
  • 146
  • 210
Doug
  • 655
  • 2
  • 6
  • 15
  • What value did you set `browser.firefox.cmd` to, and did you still have `browser.firefox.path` set? – Cascabel Feb 09 '11 at 16:56
  • I was using `cmd = open -a Firefox.app` but I found a solution. Thanks for the help. – Doug Feb 09 '11 at 17:21

2 Answers2

8

I guess you can't override the command for a known browser. What worked is using a browser name that is not firefox:

git config --global web.browser ff
git config --global browser.ff.cmd "open -a Firefox.app"
Doug
  • 655
  • 2
  • 6
  • 15
  • +1: Aha. Looking at the source, this is very obvious: there's a case (shell for `switch`) statement which checks several known browsers, and calls them with the configured path according to its known syntax, and only uses `browser.*.cmd` if none of the cases match, in which case it doesn't actually use browser.path... this is actually all documented in the `git-web--browse` manpage, which is a little inconsistent with the documentation for `git-config`. – Cascabel Feb 09 '11 at 18:31
  • The important bit is the line "you can't override the command for a known browser." This solved a similar problem I was having loading Chrome. My config is now: [web] browser = chr [browser "chr"] cmd = /usr/bin/open -a '/Applications/Google Chrome.app' – Judy2K Jan 14 '13 at 15:09
0

I'm not an OS X user, but I suppose that the shell doesn't let you pass a multi-word argument without escaping it.

Edit directly your ~/.gitconfig file and insert the following [web] section:

[web]
    browser = open -a Firefox.app 
Andrea Spadaccini
  • 12,378
  • 5
  • 40
  • 54
  • Nope, this doesn't work. I just discovered what does work is setting `web.browser` to `open`. I wish you solution worked because if you have `.html` files associated with a text editor instead of a browser, sad times. – Doug Feb 09 '11 at 17:12
  • Sorry it didn't work out. Why don't you try to use another web browser like Google Chrome for browsing the docs? – Andrea Spadaccini Feb 09 '11 at 17:16
  • @doug then why don't you answer to your own question and accept it? People who will seek for the solution of this problem will benefit from it. – Andrea Spadaccini Feb 16 '11 at 09:46