首先要做的是调试git 命令,通过添加GIT_TRACE=1 来查看它在哪个组件上失败,例如
$ GIT_TRACE=1 git svn clone https://example.com/svn/foo/ foo
21:12:40.239238 git.c:557 trace: exec: 'git-svn' 'clone' 'https://example.com/svn/foo/ foo/' 'foo'
21:12:40.240158 run-command.c:347 trace: run_command: 'git-svn' 'clone' 'https://example.com/svn/foo/ foo/' 'foo'
error: git-svn died of signal 11
并重新运行损坏的存储库中的最后一个命令,这表明崩溃发生在 git-svn 二进制文件中。
为此,您需要确定 git-svn 二进制文件的位置,例如
$ which -a git-svn
$ locate git-svn | grep git-svn$
/Applications/GitHub.app/Contents/Resources/git/libexec/git-core/git-svn
/Applications/SourceTree.app/Contents/Resources/git_local/libexec/git-core/git-svn
/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-svn
/Library/Developer/CommandLineTools/usr/libexec/git-core/git-svn
/usr/local/libexec/git-core/git-svn
/usr/local/Cellar/git/1.8.4.1/libexec/git-core/git-svn
/usr/local/Cellar/git/2.4.0/libexec/git-core/git-svn
如果您有多个 git-svn 二进制文件,要找出使用的是哪一个,请运行:
sudo fs_usage -f exec | grep git
在另一个终端再次运行失败的 git 命令之前。
一旦你确定了你运行的是哪个git-svn,就直接运行它:
/usr/local/libexec/git-core/git-svn ...
/usr/local/Cellar/git/2.4.0/libexec/git-core/git-svn
而且不管你指定哪个参数,它很可能会崩溃,否则按照跟踪输出中所示的方式指定。
有时它可能是一个符号链接,因此请检查它指向的位置,例如:
$ stat /usr/local/libexec/git-core/git-svn
File: ‘/usr/local/libexec/git-core/git-svn’ -> ‘/Applications/GitHub.app/Contents/Resources/git/libexec/git-core/git-svn’
如果是这种情况,请将符号链接更改为不会崩溃的链接,例如
$ ln -vfs /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-svn /usr/local/libexec/git-core/git-svn
‘/usr/local/libexec/git-core/git-svn’ -> ‘/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-svn’
或者确定您的git-svn 属于哪个包并相应升级,例如
-
/Applications/Xcode.app -> 升级 Xcode,
-
/Applications/GitHub.app -> 升级 GitHub 应用
-
/usr/local/Cellar/git -> 通过 Homebrew 升级 git,例如
brew upgrade git
如果 Homebrew 会抱怨文件冲突,那么运行:
brew link --overwrite git
如果升级后仍然崩溃,请使用不会崩溃的其他版本(如上所述),例如
/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-svn clone https://example.com/svn/foo/ foo
如果这对您有用,请添加到您的 PATH 并稍后使用 git-svn 命令,或添加别名,例如:
alias git-svn='/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-svn'
如果新的git-svn 缺少任何依赖项,请运行以下命令安装Git::SVN:
sudo cpan install Git::SVN
调试
如果上面没有帮助,您可以进一步调试它。以下是一些建议在单独的终端中运行,然后运行失败的命令:
sudo dtruss -fn git
或:
sudo dtruss -fn git-svn
要确定调用了哪个git-svn,您可以尝试:
sudo /usr/bin/newproc.d
sudo fs_usage -f exec | grep git