Kilimanjaro T Robbs
Kilimanjaro T Robbs

Reputation: 579

GitHub for Mac error: git: 'credential-osxkeychain' is not a git command

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?

Upvotes: 39

Views: 51067

Answers (16)

C RICH
C RICH

Reputation: 503

I got this error when using Git Graph plugin on VSCode. Before going crazy over weird bugs with no correct solutions, try restarting VSCode. While I also ran brew update, as per the other answers here, nothing truly resolved the error until I restarted VSCode.

Upvotes: 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

Upvotes: 4

iSofia
iSofia

Reputation: 1532

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

Upvotes: 11

indubitably
indubitably

Reputation: 297

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

Upvotes: 1

devstuff
devstuff

Reputation: 8387

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 [email protected]:ORG/homebrew-PRIVATE_TAP_NAME.git

Upvotes: 0

artk42
artk42

Reputation: 5

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

Upvotes: 0

plough
plough

Reputation: 81

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.

Upvotes: 5

苏大强
苏大强

Reputation: 339

enter image description here

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

brew untap homebrew/homebrew-dupes

Upvotes: 33

yz Strive
yz Strive

Reputation: 51

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

Upvotes: 5

kangkyu
kangkyu

Reputation: 6090

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

Upvotes: 19

Ahmed
Ahmed

Reputation: 719

Try : git config --global credential.helper git

Upvotes: -1

William
William

Reputation: 1315

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

Upvotes: 1

Ahmad Zain
Ahmad Zain

Reputation: 179

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

Upvotes: 6

Ralph Callaway
Ralph Callaway

Reputation: 1848

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)

Upvotes: 0

ryancwarren
ryancwarren

Reputation: 266

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.

Upvotes: 0

Kilimanjaro T Robbs
Kilimanjaro T Robbs

Reputation: 579

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

Upvotes: 14

Related Questions