Trying to install git on OSX: cannont exec 'git-credential-osxkeychain': Permission denied` - macos

I'm attempting to install Git on my new MBP and am following the documentation # https://help.github.com/articles/set-up-git.
I seem to have hit a snag at the point where it says : If you do not have the helper, you can download it and copy it to /usr/local/bin
I navigated to /usr/local/bin in terminal and did a sudo wget [link to osxkeychain]. When I try to do a git config --global credential.helper osxkeychain I get a fatal: cannont exec 'git-credential-osxkeychain': Permission denied.
What did I do wrong?
Thanks!
Tre

Download the git-credential-osxkeychain file to your desktop(!).
Open the Terminal application.
Type in the following:
sudo cp ~/Desktop/git-credential-osxkeychain /usr/local/bin/git-credential-osxkeychain
sudo chmod 755 /usr/local/bin/git-credential-osxkeychain
sudo git config --global credential.helper osxkeychain
Test it with:
sudo git credential-osxkeychain
See the sudo prefix? It seems to be required for the credential stuff... It should now output Usage: git credential-osxkeychain <get|store|erase>

Make the downloaded file executable:
chmod 755 git-credential-osxkeychain

Homebrew's git package sets this up; just:
brew install git
and you're away.

Tried sudo?
/usr/bin is protected. Or you could try downloading git executables somewhere on your laptop and add that location to your PATH.

One of the common mistakes made by people starting on git is that they have the wrong executable for the operating system.
Please make sure that when you go to git help setup page you click on the right link
for example the following link has MAC | WINDOWS | LINUX | ALL options in the top of the page which is small enough to be ignored by many.
https://help.github.com/articles/set-up-git
This has happened to many of my team member to install osx for ubuntu and end up getting the error mentioned above

Related

Updated Git but still showing old version

I downloaded and installed Git 1.8.4.2 from this link: http://git-scm.com/downloads. However, when I run git --version from the Terminal I get:
[~/workspace/ruby]: git --version
git version 1.7.4.4
I've tried restarting the terminal and my computer. I then tried using the info at https://code.google.com/p/git-osx-installer/wiki/Uninstall. I did the following in the terminal from within /usr:
sudo rm -rf /usr/local/git
sudo rm /etc/paths.d/git
sudo rm /etc/manpaths.d/git
I then ran the new git .dmg file again but am still getting 1.7.4.4 when I run git --version. I suppose there's something going on here with the Mac filesystem that I don't understand. Any help would be greatly appreciated!
Run the command:
which git
You'll probably see /usr/bin/git -- the Apple supplied version. This will be because /usr/bin appears in your PATH environment variable before /usr/local/git/bin. You can verify this by running the command:
echo $PATH
If that is the case then run this command:
export PATH=/usr/local/git/bin:$PATH
and then try git --version again. You should now get 1.8.4.2. This hasn't fixed it permanently yet though. You'll need to add the export PATH=... line to your ~/.bashrc so that it gets set for every shell.

The git user is unable to execute bundle during GitLab installation

I am trying to install GitLab on a Debian Wheezy and experiencing an issue I don't understand.
Following the install guide for version 5.0:
step 1: was run as explained
step 2: I used rvm (multi-user install) instead (ruby-1.9.3-p392)
steps 3 to 5: were run as explained (MySQL chosen)
step 6: everything works fine until the "Install Gems" section, where I get the following error:
/home/git/gitlab$ sudo -u git -H bundle install --deployment --without development test postgres
sudo: unable to execute /usr/local/bin/bundle: No such file or directory
I run this as my normal user (in the sudo and rvm groups), and the git user is not a sudoer.
I think that the line sudo gem install bundler, in step 2, does not grant the git user to execute bundle properly, but I don't know how to fix this.
I probably did something wrong but cannot figure out what it is, as I tried to respect the standard instructions as close as possible.
Any clue about this? Thanks, I am losing hope...
For information, I have written to the GitLab mailing-list about this problem but did not get any answer. Moreover, last time I asked something similar on ServerFault, I have been advised to post on StackOverflow instead... hence this question :)
When I do $ which bundle, I get /usr/local/rvm/gems/ruby-1.9.3-p392/bin/bundle.
The git user has been created with the --disabled-login flag and thus I cannot login as git to run bundle.
When I do $ sudo -u git bundle, I get
sudo: unable to execute /usr/local/bin/bundle: No such file or directory
That means git user has not /usr/local/rvm/gems/ruby-1.9.3-p392/bin in its PATH, and you cannot modify its .profile or .bashrc because of the --disabled-login flag.
It seems that running sudo -i -u git bundle instead of sudo -u git bundle does the trick
That is the safest route, and will execute the command as git, but will simulate first an initial login, using the PATH defined in .profile and .bashrc of user root.
See "How does sudo search the path for executable?" for more.
On my local machine after upgrade from 6.4 to 7.7 I had such issue.
The compilation of ruby was made under root account.
So need permissions to read compiled ruby and installed bundle.
chmod ugo+rx /usr/local/bin/bundle
chmod -R ugo+rX /usr/local/lib/ruby/
In production mode You could be more strict.

Git hanging after installing osx credential helper

I'm having the same problem as this thread: Git hangs indefinitely - broke with osx credential helper I think
Basically -- had been running git without problems, then installed the credential-osxkeychain and git began hanging indefinitely after any command. e.g., running git init results in a hanging prompt and any input creates an error: bad input
I tried following the advice to delete git from usr/bin/git but now it doesn't recognize anything. I tried reinstalling git but now it doesn't seem to recognize it.
I ran which git and it returns: /usr/local/git/bin/git
I'm somewhat new at this and don't have the balls to just start running sudo commands and moving things around in the /usr/bin directory.
Any ideas what I can do to fix this?
I had the same problem and fixed it thusly:
uninstall git via the uninstall.sh that comes with the install
reinstall git via the installer
run which git and cd to the folder containing git (eg. cd /usr/local/git/bin/)
run curl -O http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain
run chmod u+x git-credential-osxkeychain
run git config --global credential.helper osxkeychain
Fixed.
Still not totally sure what I actually did to fix this problem, but resetting the terminal ended up getting it to work.
I had the same problem.
I didnt have git 1.7.10 or later installed. Messed everything up.
To fix, I had to delete git and install a newer version.
I used homebrew to install, after deleting.
is working again.
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

How to fix git config issue where all commands go to blank line?

I am not new to git but I am newer to github and still a beginner with bash. I was trying to set some config stuff and ending up breaking git on my local machine. Here's what I did following these instructions on github for password caching.
$ git config --global user.name 'myusername'
$ git config --global user.email 'myemail#email.com'
$ git credential-osxkeychain
git: 'credential-osxkeychain' is not a git command. See 'git --help'.
$ curl -s -O http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain
$ chmod u+x git-credential-osxkeychain
$ which git
/usr/bin/git
$ sudo mv git-credential-osxkeychain /usr/bin/git
$ git config --global credential.helper osxkeychain
^?^C
After this command git I received no response, just a new line which I eventually ctrl+c'ed out of. Now, whenever I do a git command in any repo, not just this one, the cursor just moves to a new line. I'm unable to push/pull/clone or do use of the commands I normally use.
I've tried reinstalling the latest version of git and still have the problem. What should I do?
Update:
I've tried unsetting credential.helper and uninstalling and reinstalling git. Still seeing the same behavior. I noticed that if I run just $ git the response is Usage: git credential-osxkeychain <get|store|erase>. At this point, I just want to delete credential-osxkeychain. Still unsuccessful.
As requested, the output of which -a git is:
$ which -a git
/usr/bin/git
/usr/local/git/bin/git
When you ran this command:
$ sudo mv git-credential-osxkeychain /usr/bin/git
You overwrote the existing git executable with the git-credential-osxkeychain executable. That script is only meant to be run as a sub-command of Git, not standalone.
If you use Time Machine, you can try to restore the old /usr/bin/git from a backup. Otherwise, you'll need to reinstall Git.
Based on the comments below, it appears that /usr/bin/git is actually still git-credential-osxkeychain, probably because Git installed itself into /usr/local instead of /usr/bin.
If you don't care about the keychain behavior anymore, you can remove the current git executable altogether:
$ sudo rm /usr/bin/git
That may cause Git to start working for you immediately if /usr/local/git/bin is in your path. Or you could simply move it to /usr/local/git/bin/git-credential-osxkeychain:
$ sudo mv /usr/bin/git /usr/local/git/bin/git-credential-osxkeychain
which (again, assuming your path is correct) should allow you to use it as a credential helper like you originally wanted.

Error while trying to update brew package manager

I tried to update brew:
sudo brew update
But I got this error:
error: Your local changes to the following files would be overwritten by merge:
Listing a lot of files
Error: Failed while executing git pull http://github.com/mxcl/homebrew.git master
Any idea what is going wrong?
There was a bug in Homebrew that was fixed just a few days ago. To fix the bug you can run git reset --hard FETCH_HEAD inside your Homebrew installation. Since that won't fix files that are already seen as modified you can also run git checkout Library to replace your checkout with the latest files. (That wipes all edits so take appropriate measures with any you made.)
The accepted answer is correct but incomplete. If you are getting the error of
error: The following untracked working tree files would be overwritten by merge:
Then go to your terminal and run these commands
cd /usr/local
Then
git reset --hard FETCH_HEAD
Then
git checkout Library
That should get everything in order. Then run
brew update
Let me add: cd /usr/local/git
and then run git reset --hard FETCH_HEAD
go to your terminal and run these commands
cd /usr/local
sudo git reset --hard FETCH_HEAD
sudo git checkout Library
For those of you using OS X El Capitan, your problem may be System Integrity Protection.
If /usr/local exists already, run the following in Terminal:
sudo chown -R $(whoami):admin /usr/local
If /usr/local does not exist:
First, try to create /usr/local the normal way:
sudo mkdir /usr/local && sudo chflags norestricted /usr/local && sudo chown -R $(whoami):admin /usr/local
If you see permission issues instead try:
Reboot into Recovery mode (Hold Cmd+R on boot) & access the Terminal.
In that terminal run: csrutil disable
Reboot back into OS X
Open your Terminal application and execute the line from just above
Reboot back into Recovery Mode & access the Terminal again.
In that terminal execute: csrutil enable
Reboot back into OS X & you'll be able to write to /usr/local & install Homebrew.
Out of no reason (or at least no one I'd understand) the repository in /usr/local (which is the brew install!) lost its remote repository. So, neither a git reset nor a git pull and for sure no brew update would work.
How do you know that happened? Check /usr/local/.git/config whether there are some lines like the following:
[remote "origin"]
url = http://github.com/mxcl/homebrew.git
fetch = +refs/heads/*:refs/remotes/origin/*
If not do as follows:
cd /usr/local
git remote add origin http://github.com/mxcl/homebrew.git
git pull origin master

Resources