如何在Mac上开始使用Git [英] How to get started with Git on Mac

查看:501
本文介绍了如何在Mac上开始使用Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我从 http://code.google.com/p/git-osx-installer/downloads/list?can=3
,然后我下载了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.sh

  • uninstall.sh



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


没有改变PATH 〜/ .MacOSX / environment.plist点击
〜/卷/ 1.7.3.5的Git x86_64的豹纹
/卷/ 1.7.3.5的Git x86_64的豹纹
-MacBook-PRO:Git的1.7。 3.5 x86_64 Leopard $ $ PATH
-bash:/ usr / local / bin:/ bin:/ sbin:/ usr / bin:/ usr / sbin:/ usr / libexec:没有这样的文件或目录



更新2:



我的个人档案文件的内容如下一个:
$ b $ pre $ #系统范围.profile for sh(1)

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

if [$ {BASH-no}!=no];然后
[-r / etc / bashrc]&& 。 / etc / bashrc
fi


解决方案

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



您是否运行包含的shell脚本为非终端程序设置git PATH.sh

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




  1. 挂载git双击 git-1.7.3.5-x86_64-leopard.dmg ,这应该位于下载 code>文件夹。

  2. / Applications / Utilities / Terminal
  3. 打开终端
  4. 输入 cd / Volumes / Git 1.7.3.5 x86_64 Leopard /

  5. 键入 ./ setup git PATH for非终端程序.sh 并点击Enter运行shell脚本。注意:键入 ./ setup 后,您可以点击Tab键并自动完成。
  6. 打开一个新的终端并键入 echo $ PATH

  7. 确认您看到 / usr / local / git / bin


  8. 更新2:显示Git谁是主人



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

      echo/ usr / local / git / bin> git 
    sudo mv git /etc/paths.d

    运行sudo时,它会询问为您的OS X密码。

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

    为此,您必须在 / etc / profile 中包含以下内容:

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


    I installed Git on my Mac but I do not know how to run it or access it. From the terminal I type git but it says "command is invalid."

    I downloaded git from http://code.google.com/p/git-osx-installer/downloads/list?can=3 and I downloaded the package "Git Installer 1.7.3.5 - OS X - Leopard - x86_64."

    UPDATE 1:

    The content of the package is the following:

    • README.txt
    • git-1.7.3.5-x86_64-leopard.pkg
    • setup git PATH for non-terminal programs.sh
    • uninstall.sh

    When I execute "setup git PATH for non-terminal programs.sh," I get the following messages:

    No change to PATH in ~/.MacOSX/environment.plist
    ~ /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: No such file or directory

    UPDATE 2:

    The content of my profile file is the following one:

    # 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
    

    解决方案

    The git-osx-installer that you used should have installed git into /usr/local/git. See if you can cd into that directory. If you can, then check that your PATH was correctly set by running echo $PATH from the terminal and making sure that you see /usr/local/git/bin in the included PATH. If not, you need to add it to your PATH.

    Did you run the included shell script setup git PATH for non-terminal programs.sh?

    Update 1: How to run the included shell script

    1. Mount the git-osx-installer disk image by double-clicking git-1.7.3.5-x86_64-leopard.dmg, which should be located in your Downloads folder.
    2. Open Terminal from /Applications/Utilities/Terminal
    3. Type cd /Volumes/Git 1.7.3.5 x86_64 Leopard/
    4. Type ./setup git PATH for non-terminal programs.sh and hit Enter to run the shell script. Note: Once you type ./setup you can hit the Tab key and it will autocomplete for you.
    5. Open a new Terminal and type echo $PATH
    6. Confirm that you see /usr/local/git/bin in your PATH.

    Update 2: Show Git Who's the Master

    Open Terminal and issue the following commands:

    echo "/usr/local/git/bin" > git
    sudo mv git /etc/paths.d
    

    When you run sudo it will ask for your OS X password.

    After issuing those two commands, you should be able to open a new Terminal window and see /usr/local/git/bin when you run echo $PATH.

    For this to work you have to have the following in /etc/profile, which it does by default:

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

    这篇关于如何在Mac上开始使用Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆