"git pull"坏了

Ovi*_*vid 13 git macos osx-snow-leopard

我最近将我的MacBook Pro升级为Snow Leopard并且"git pull"返回:

rakudo $ git pull
git: 'pull' is not a git-command. See 'git --help'

Did you mean this?
        shell
rakudo $ git-pull
-bash: git-pull: command not found
Run Code Online (Sandbox Code Playgroud)

我试过通过macports重新安装,但无济于事.然后我看到了这个

rakudo $ git --exec-path
/Users/ovid/libexec/git-core
Run Code Online (Sandbox Code Playgroud)

这令我感到惊讶,因为该目录不存在,也不存在.谷歌没有帮助.希望你能:)

Dom*_*ell 24

查看git的源代码,git.c中有一条注释:

/*
 * We use PATH to find git commands, but we prepend some higher
 * precedence paths: the "--exec-path" option, the GIT_EXEC_PATH
 * environment, and the $(gitexecdir) from the Makefile at build
 * time.
 */
Run Code Online (Sandbox Code Playgroud)

如果你打电话git --exec-path,你最终会调用const char *git_exec_path(void)exec_cmd.c.看起来像这样:

const char *env;

if (argv_exec_path)
    return argv_exec_path;

env = getenv(EXEC_PATH_ENVIRONMENT);
if (env && *env) {
    return env;
}

return system_path(GIT_EXEC_PATH);
Run Code Online (Sandbox Code Playgroud)

现在,_argv_exec_path_设置为当你说--exec-path=/some/where这样可以打折.您已声明未设置环境变量. GIT_EXEC_PATHMakefile中编译时定义.向后看,它似乎被定义为公正libexec/git-core.因此,我们需要查看system_path()的作用.

我不确定是否RUNTIME_PREFIX为你定义.但是在Makefile中输入时,我确实注意到前缀默认为$(HOME).我怀疑这可能是你问题的原因.

简单的答案就是把它放进去~/.bashrc:

export GIT_EXEC_PATH=/opt/local/libexec/git-core
Run Code Online (Sandbox Code Playgroud)

如果你想了解更多有关正在发生的事情,你可能需要使用port -d upgrade -f git-core(或类似的)重新编译git 并仔细查看构建日志以查看正在设置前缀的位置.顺便说一句,port cat git-core显示大量使用${prefix}它应该(希望)显而易见.

  • 只是澄清了其他任何发现这一点的人:git命令的路径确实在编译时设置(虽然可以通过GIT_EXEC_PATH修改,然后通过--exec-path修改).这很可能是在编译时通过`make prefix =/path/to/git ...`设置的.希望任何预先构建的版本都能正确执行此操作! (3认同)