36

When using the GitHub for Mac app (version 87), I received the following error:

git: 'credential-osxkeychain' is not a git command. See 'git --help'.

error: The requested URL returned error: 403 while accessing https://github.com/[PROJECT URL]/info/refs

fatal: HTTP request failed (256)

The git command-line tools (version 1.8.0) are installed at /usr/local/git/bin and git-credential-osxkeychain was correctly installed at /usr/local/git/bin.

How can I solve this error?

hopper
  • 13,060
  • 7
  • 49
  • 53
  • 2
    I did not type anything, I hit the Sync button. I have a solution, but stackoverflow will not allow me to post it until after 8 hours since I am a new user. – Kilimanjaro T Robbs Dec 01 '12 at 17:47
  • `sudo ln -s /usr/local/git/bin/git-credential-osxkeychain /usr/local/bin/git-credential-osxkeychain` should fix it. @William has a similar answer though he created the softlink in `/usr/bin` instead of `/usr/local/bin` – Abhijit Sarkar Sep 26 '16 at 03:04

15 Answers15

33

enter image description here

When I tried to run this command, there was no error

brew untap homebrew/homebrew-dupes
Ramprasath Selvam
  • 3,868
  • 3
  • 25
  • 41
苏大强
  • 339
  • 3
  • 3
17

git: 'credential-osxkeychain' is not a git command. See 'git --help'. this error message's gone after I upgraded git, with

brew upgrade git

==> Upgrading 1 outdated package:
git 2.11.1 -> 2.21.0
kangkyu
  • 5,252
  • 3
  • 34
  • 36
14

The source of this problem is that GitHub for Mac uses a different directory path for its executables than the Command Line Tools.

GitHub for Mac: /Applications/GitHub.app/Contents/Resources/git/bin

Command Line Tools: /usr/local/git/bin/

So when GitHub for Mac tries to Sync a Branch it presents the error because it can not find git-credential-osxkeychain executable file.

To solve the problem:

  1. Launch Terminal
  2. Create a Symbolic Link for git-credential-osxkeychain from Command Line Tools Dir to GitHub for Mac Dir

ln -s <git-command-line-tools dir path>/git-credential-osxkeychain <github for mac path>/git-credential-osxkeychain

This is the command I used on my system:

ln -s /usr/local/git/bin/git-credential-osxkeychain /Applications/GitHub.app/Contents/Resources/git/bin/git-credential-osxkeychain

  • 6
    I had the same problem with Atlassian's `SourceTree` app - the underlying problem was the same. I was able to resolve the issue by switching from the `SourceTree`'s embedded git to the globally installed one - which happened to be recent enough - by selecting `SourceTree > Preferences > Git`, `Use System Git`. Also note that Github for Mac now allows you to go the opposite direction: you can opt to have its embedded git version act as the globally installed one via `Preferences`. – mklement0 Oct 30 '13 at 22:42
  • 2
    The solution works the same for SourceTree, only the target of the link becomes `/Applications/SourceTree.app/Contents/Resources/git_local/bin` The current version of the Mac git client includes `git-credential-osxkeychain`, so +1 for pointing to the `Use System Git` preference. That's probably the way it "should" be done for SourceTree users. Otherwise, if/when git updates and SourceTree does not, `git-credential-osxkeychain` will have a version mismatch with the rest of the git executables that SourceTree will be using. – Chris Ostmo Nov 19 '13 at 17:10
  • This also happens for SmartGit for mac. Solution is the same for smartgit `ln -s /usr/local/git/bin/git-credential-osxkeychain /Applications/SmartGit.app/Contents/Resources/git/bin/git-credential-osxkeychain` – hitautodestruct Jun 02 '16 at 11:10
6

this always happens with source tree app and the solution that you change the settings to use the system git not the embedded git with source-tree because source tree is using an older version or you can update the settings with the path to git executable and you should find it in /usr/bin/git or you can print which git and point your Source tree app to use it

Community
  • 1
  • 1
Ahmad Zain
  • 179
  • 1
  • 2
  • 8
5

http://backlogtool.com/git-guide/cn/reference/trouble-shooting.html

HTTPS requires passwords every time you execute push/pull if you are windows,Just for the first time

but in Mac, you can use the authentication assistant connected with the key chain. Users using Homebrew automatically install authentication assistants when installing Git. In addition, you need to install manually.

If you want to verify that you have an installation certification assistant, you can use the following command to confirm.

git credential-osxkeychain

If the authentication assistant is not installed, the following contents are displayed.

git: 'credential-osxkeychain' is not a git command. See 'git --help'.

At this point, you can download the authentication assistant to the right path.

  1. curl -s -O http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain
  2. chmod u+x git-credential-osxkeychain
  3. mv git-credential-osxkeychain /usr/local/bin

After installation, set the open authentication assistant.

  1. git config --global credential.helper osxkeychain
Community
  • 1
  • 1
yz Strive
  • 51
  • 1
  • 1
  • In my case on the Mac it was installed, and confirmed it with `git credential-osxkeychain`. But I had to run the 4th command to reconfigure it `git config --global credential.helper osxkeychain` – Mark Nov 19 '19 at 00:06
5

If you meet this problem when use brew update, try

brew update --debug --verbose

You can see the detail log, and find the real reason.

plough
  • 81
  • 1
  • 7
4

For the benefit of others, this resolved the issue for me.

In Fork > Preferences > Git > Git Instance: select the system version instead of the Fork instance.

https://github.com/fork-dev/Tracker/issues/1397#issuecomment-971524707

iSofia
  • 1,412
  • 2
  • 19
  • 36
1

I had to do sudo ln -s /usr/local/git/bin/git-credential-osxkeychain /usr/bin/git-credential-osxkeychain because I upgraded git and then copied /usr/local/git/bin/git to /usr/bin/git

William
  • 1,295
  • 1
  • 10
  • 19
1

I struggled with this for some time but found this solved the problem for me.

Step 1 check you have git credential-osxkeychain

$ git credential-osxkeychain
# Test for the cred helper
> Usage: git credential-osxkeychain <get|store|erase>

if not install Xcode Command Line Tools (xcode-select --install), or brew install git

Step 2 Tell Git to use osxkeychain helper using the global credential.helper config:

$ git config --global credential.helper osxkeychain
#Set git to use the osxkeychain credential helper
indubitably
  • 297
  • 2
  • 7
0

Setting

/usr/local/git/bin/git-credential-osxkeychain

in your path also works, or wherever your path may be.

I'm not sure which solution is preferable though.

ryancwarren
  • 256
  • 3
  • 8
0

After having worked through this with one of my colleagues we were able to resolve by simply updating SourceTree to the latest version.

For future viewers, before going down the symlink path, make sure you have automatic updates enabled for source tree (preferences->update tab), and then check for updates (in the source tree menu on macs)

Ralph Callaway
  • 1,768
  • 1
  • 15
  • 34
0

I've got the same issue with Fork.app, the app's git instance failed to work with keychain, that helped (or changing to system or homebrew git instance, it is listed in app's prefrences):

cd /Volumes/Macintosh HD/Applications/Fork.app/Contents/Resources/git-instance/bin

./git config --global credential.helper osxkeychain
artk42
  • 3
  • 1
0

Like @plough's answer, I had the same issue when running brew update due to the use of a private tap which uses HTTPS to access the remote repository.

The root cause is that git can't find the configured credential helper because, by default, brew will clear out the PATH from the environment.

There are two workarounds.

  1. HOMEBREW_NO_ENV_FILTERING=1 brew update leaves PATH alone, so your current git installation will be used and the credential helper will be found. This is a bit unwieldy to type each time so if you use this solution save it as an alias or a 1-liner script.

    Update: You can also use HOMEBREW_FORCE_BREWED_GIT=1 brew update to use the brew-installed git instead of the system one. This version finds the credential helper without relying on the path being set.

  2. My preferred workaround is to change the remote URL of the offending tap to use a SSH-style URL (and make sure you have a valid SSH key configured). You don't have to remember a different incantation for brew update and it is permanent.

    • In a terminal, cd /usr/local/Homebrew/Library/Taps/ORG/homebrew-PRIVATE_TAP_NAME
    • git config remote.origin.url will show a value of https://github.com/ORG/homebrew-PRIVATE_TAP_NAME
    • change it to the equivalent SSH-style URL: git config remote.origin.url git@github.com:ORG/homebrew-PRIVATE_TAP_NAME.git
devstuff
  • 8,277
  • 1
  • 27
  • 33
0

I had the same issue with Fork and the solution was to change git instance selection from preferences.

Just navigate to Fork -> Preferences -> Git and choose /usr/bin/git at the drop down selection. With the 'Fork instance' option selected I was facing the same issue.

See image below:

enter image description here

-1

Try : git config --global credential.helper git

Ahmed
  • 689
  • 6
  • 14