4

I got tired of typing my password for my bitbucket repo so I looked up a way to use ssh keys but happened upon the osx credential keychain. I thought I had installed it all correctly by following along with what was instructed in the git-scm book but something bad happened...I can't use git at all!! I then went and rm'd the credential-osxkeychain but that didn't fix my issue, neither did uninstalling and reinstalling git.

If I go into a repo that I had previously pulled down, change a file and run git status it hangs indefinitely.

If I make a new directory, cd into it and run git init that will hang indefinitely as well.

When I run git without any arguments the following is printed out: Usage: git credential-osxkeychain <get|store|erase>. I already looked at my /Applications/Utilities/Keychain Acces.app but I couldn't find anything to change. At this point I just want git back...I'm fine with typing my password.

For reference I am using OSX 10.7.2

edited to add: which git returns /usr/bin/git

dreamriver
  • 1,291
  • 2
  • 15
  • 20

3 Answers3

5

To fix this I reinstalled git from http://git-scm.com/download/mac and then added /usr/local/git/bin to the top of the file /etc/paths

Dan2552
  • 1,244
  • 1
  • 15
  • 26
  • Never thought of that. Nice work. Worked. `mv /usr/bin/git /usr/bin/git_old` `ln -s /usr/local/git/bin/git /usr/bin/git` – Saeven Feb 18 '14 at 17:07
4

Try "git" status (with the quotes). If that works, you've aliased git to something else (probably alias git="git credential-osxkeychain"), and you should look in ~.profile to see if you can remove the alias.

(See the attached commentary for the debugging steps and eventual resolution).

nneonneo
  • 171,345
  • 36
  • 312
  • 383
  • I thought it was \ that made it go around aliases. I tried both regardless, neither worked. I also looked in `.bash_profile`, `.bashrc` and `.gitconfig` – dreamriver Sep 27 '12 at 02:46
  • \ works too; I'm just used to `"..."`. Did you perchance replace `git` with some sort of wrapper? What does `which git` produce? – nneonneo Sep 27 '12 at 02:48
  • just edited my post to say `which git` returns `/usr/bin/git` – dreamriver Sep 27 '12 at 02:49
  • `less /usr/bin/git` produces binary gibberish? Maybe use `Instruments.app` or `dtrace` to figure out what this apparently-modified `git` is doing? – nneonneo Sep 27 '12 at 02:53
  • yeah, binary gibberish indeed. actually...some of it is legible for whatever reason. and it says something like `/usr/local/share/git-core/contrib/credential/osxkeychain` or `/usr/local/Cellar/git/1.7.10/share/git-core/contrib/credential/osxkeychain/git-credential-osxkeychain` – dreamriver Sep 27 '12 at 02:56
  • 7
    It looks like you installed the `git-credential-osxkeychain` wrapper in the wrong place (did you `cp` to `/usr/bin/git` instead of `/usr/local/git/bin`?) To fix, you'll want to just delete `/usr/bin/git`; assuming `git` is still installed in `/usr/local/bin` it should take over. – nneonneo Sep 27 '12 at 03:00
  • Your issue would make sense given that the credential helper likely calls back to `git`, which would result in an infinite `exec` loop. – nneonneo Sep 27 '12 at 03:02
  • 1
    Thanks a lot! It works now. I was going to try that but I guess I didn't really have the balls to do so without an internet recommendation. It's actually installed to `/usr/local/git/bin` so I just added that to my PATH. – dreamriver Sep 27 '12 at 03:06
  • This worked for me and I reinstalled from brew so it had the osxkeychain already. Maybe you should add the commentary resolution to the answer? Thanks! – Chris Butler Oct 17 '12 at 15:38
  • Hehe, I had this problem and it turned out that I copied osxkeychain to `/usr/local/git/bin/git` rather than `/usr/local/git/bin/`. D'oh! – starwed Nov 21 '12 at 19:02
0

As nneonneo said above, the reason is that files - git-credential-osxkeychain and git - are installed on wrong path (path, which is not default in /etc/paths, which is not on the first line in /etc/paths). Answers above didn't work for me. What exactly I tried : 1) change order of lines in file /etc/paths, but file /etc/paths is not available for changing on Mavericks 2) delete /usr/bin/git - this also didn't help me 3) mv /usr/bin/git /usr/bin/git_old ln -s /usr/local/git/bin/git /usr/bin/git also didn't. So I decided to describe my way. I manually take files - git-credential-osxkeychain and git from /usr/local/git/bin and put in /usr/bin/git (cause /usr/bin/git - is the first path in /etc/paths). To get the path like /etc/paths in finder, just push Command+Shift+G and put path.

NikLanf
  • 1,663
  • 1
  • 11
  • 14