如何在Mac上开始使用Git

joh*_*doe 18 git macos

我在我的Mac上安装了Git,但我不知道如何运行它或访问它.从终端我输入git,但它说"命令无效".

我从http://code.google.com/p/git-osx-installer/downloads/list?can=3下载了git, 然后我下载了"Git Installer 1.7.3.5 - OS X - Leopard - x86_64"软件包.

更新1:

包的内容如下:

  • 的README.txt
  • GIT-1.7.3.5-x86_64的,leopard.pkg
  • 为非终端程序设置git PATH
  • uninstall.sh

当我执行"setup git PATH for non-terminal programs.sh"时,我收到以下消息:

在〜/ .MacOSX/environment.plist中没有改变PATH
~/Volumes/Git 1.7.3.5 x86_64 Leopard/Volumes/Git 1.7.3.5 x86_64 Leopard -MacBook-Pro:Git 1.7.3.5 x86_64 Leopard $ $ PATH -bash:/ usr/local/bin:/ bin:/ sbin:/ usr/bin:/ usr/sbin:/ usr/libexec:没有这样的文件或目录

更新2:

我的个人资料文件的内容如下:

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc
fi
Run Code Online (Sandbox Code Playgroud)

Mat*_*kin 22

您使用的git-osx-installer应该已经安装了git /usr/local/git.看看你是否可以cd进入该目录.如果可以,请检查您PATH是否通过echo $PATH从终端运行并确保/usr/local/git/bin在包含的内容中看到了您的设置PATH.如果没有,您需要将其添加到您的PATH.

你运行了包含的shell脚本setup git PATH for non-terminal programs.sh吗?

更新1:如何运行包含的shell脚本

  1. 双击安装git-osx-installer磁盘映像git-1.7.3.5-x86_64-leopard.dmg,该映像应位于您的Downloads文件夹中.
  2. 打开终端 /Applications/Utilities/Terminal
  3. 类型 cd /Volumes/Git 1.7.3.5 x86_64 Leopard/
  4. 键入./setup git PATH for non-terminal programs.sh并按Enter键以运行shell脚本.注意:键入后,./setup您可以点击Tab键,它将自动完成.
  5. 打开一个新的终端并输入 echo $PATH
  6. 确认您/usr/local/git/bin在PATH中看到了.

更新2:显示Git谁是主人

打开终端并发出以下命令:

echo "/usr/local/git/bin" > git
sudo mv git /etc/paths.d
Run Code Online (Sandbox Code Playgroud)

当你运行sudo时,它会询问你的OS X密码.

发出这两个命令后,您应该能够打开一个新的终端窗口,看看/usr/local/git/bin您何时运行echo $PATH.

要使其工作,您必须具有以下内容/etc/profile,默认情况下执行此操作:

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
fi
Run Code Online (Sandbox Code Playgroud)


mik*_*iku 5

一般介绍:

Git Immersion是一个导游,介绍了Git的基础知识,其灵感来自于知道要做到这一点的前提.