我按照下面的教程安装 git。
https://help.github.com/articles/set-up-git
然而,当我最后需要将助手安装到 Git 本身的同一目录中时,我收到以下错误:
Davids-iMac:~ davidcavanagh$ which git
/usr/bin/git
Davids-iMac:~ davidcavanagh$ sudo mv git-credential-osxkeychain /usr/bin
mv: rename git-credential-osxkeychain to /usr/bin/git-credential-osxkeychain: No such file
or directory
Davids-iMac:~ davidcavanagh$
编辑:当我安装 git 然后运行 git -version 时,出现以下错误
Davids-iMac:~ davidcavanagh$ git -version
/usr/bin/git: line 1: syntax error near unexpected token `newline'
/usr/bin/git: line 1: `<?xml version="1.0" encoding="UTF-8"?>'
I was following this tutorial guide:https://help.github.com/articles/set-up-git
我也尝试过使用 home-brew 但这样做时出现以下错误:
Davids-iMac:~ davidcavanagh$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
Press ENTER to continue or any other key to abort
==> Downloading and Installing Homebrew...
Failed during: git init -q
有人能帮忙吗?谢谢
答案1
您需要下载该程序,正如指南中您遇到问题的代码上方几行中所说的那样。
git credential-osxkeychain # Test for the cred helper
# 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 # Download the helper
chmod u+x git-credential-osxkeychain # Fix the permissions on the file so it can be run
答案2
在 OSX 上使用自制安装git
。使用简单的单行命令安装 homebrew 后,输入以下命令:
brew update
brew install git
答案3
尝试了所有方法后,我通过使用 Xcode 更新命令行工具解决了这个问题。可以在这里完成: https://developer.apple.com/downloads/index.action#或者进入 Xcode--->Preferences----->Downloads
答案4
下载 Git 安装程序– 下载的标题为“Snow Leopard”,但该软件包在 Lion 和 Mountain Lion 上均可正常运行。
打开 Mac 的“系统偏好设置”,选择“安全和隐私”
在“允许从以下位置下载应用程序”下,确保已选择“任何地方”
打开在步骤1中下载的DMG并安装该包。
打开终端并运行以下命令:
sudo mkdir -p /usr/local/bin sudo ln -s /usr/local/git/bin/git /usr/local/bin/git exit
重新打开终端并运行以下命令:
git –-version
用法:git [--version] [--exec-path[=]] [--html-path] [--man-path] [--info-path] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dir=] [--work-tree=] [--namespace=] [-c name=value] [--help] []
你已准备好出发...