Git 别名问题

发布于 2024-09-28 20:29:04 字数 317 浏览 1 评论 0原文

我试图通过将这些行添加到我的 ~/.gitconfig 文件中来设置一些 git 别名:

[alias]
  st = status
  ci = commit
  br = branch

当我在终端中运行这些命令时:git st,我收到以下错误致命:无法执行'git-st':不是目录。我不知道问题是什么,我在网上查看过,但找不到它为什么这样做。我正在使用 Git 1.7.1 运行 Mac OS 10.6.4。有人请帮帮我。如果我不明白它为什么这样做,我会发疯的!谢谢!

I was trying to set up some git aliases by adding these lines to my ~/.gitconfig file:

[alias]
  st = status
  ci = commit
  br = branch

And when I go to run these commands in the terminal: git st, I get the following error fatal: cannot exec 'git-st': Not a directory. I do not know what the problem is and I have looked online and cannot find why it is doing this. I am running Mac OS 10.6.4 using Git 1.7.1. Somebody please help me out. If I don't figure out why it is doing this, I'll go crazy! Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

情魔剑神 2024-10-05 20:29:04

unutbu 正确指出了 git-osx-installer 问题 53,其中指出:

基本上,我的路径中有 /root/bin 并且没有该目录的权限。

有趣的是,这不是 git 1.6.3 的问题,而是 1.7.0 和 1.7.1 的问题。

strace -f -eexecve git st 2>&1 | A strace -f -eexecve git st 2>&1 | grep EACC 可以帮助查看哪个目录出现问题:(

[pid 6469] execve("/usr/games/bin/git-st", ["git-st"], [/* 72 vars */]) = -1 EACCES

在本例中为 /usr/games/bin/

另一种查找有问题的路径的方法是:

echo $PATH |tr ':' '\n' |xargs ls -ld

我的无效项目之一实际上是一个 NFS 安装目录,我无权访问该目录,因为我尚未通过 Kerberos 向公司 NFS 服务器进行身份验证。
PATH 中删除一项可以解决该问题,并且“git stat”(我的状态别名)现在可以工作。


PeterT 在评论中提到您可能没有 strace 可用(就像在 Solaris 中< a href="http://opensourcehacker.com/2011/12/02/osx-strace-equivalent-dtruss-seeing-inside-applications-what-they-do-and-why-they-hang/" rel=" noreferrer">或 OsX,详见“相当于 mac os X 上的 strace -feopen"),在这种情况下 dtruss 是一个很好的等效项。

dtruss -f -t execve git st 2>&1 | grep EACC

unutbu correctly pointed out to the git-osx-installer issue 53, which states:

Basically, I had /root/bin in my path and didn't have permissions for that directory.

Interestingly, this was not a problem with git 1.6.3, but it was with 1.7.0 and 1.7.1.

A strace -f -eexecve git st 2>&1 | grep EACC can help see what directory is the problem:

[pid 6469] execve("/usr/games/bin/git-st", ["git-st"], [/* 72 vars */]) = -1 EACCES

(in this instance, the /usr/games/bin/)

Another way to find the path with the problem is:

echo $PATH |tr ':' '\n' |xargs ls -ld

One of my invalid items is actually an NFS mounted directory that I don't have permission to access because I have not authenticated via Kerberos to the corporate NFS server.
Removing that one item from the PATH fixes the issue, and 'git stat' (my alias for status) now works.


PeterT mentions in the comment that you might not have strace available (like in Solaris or OsX, as detailed in "Equivalent of strace -feopen < command > on mac os X"), in which case dtruss is a good equivalent.

dtruss -f -t execve git st 2>&1 | grep EACC
铁憨憨 2024-10-05 20:29:04

我也遇到了这个问题,但原因略有不同:

在我的情况下,路径包含一个文件而不是目录的条目。文件本身及其目录的权限都很好。当加载新终端时,可以从任何地方运行该文件。然而,git 给出了相同的错误消息。

因此,除了在路径上查找权限不正确的文件夹之外,我建议遇到此问题的其他人也检查该路径是否仅指向文件夹而不指向文件。

I had this problem too but with a subtly different cause:

In my case the path contained an entry that was a file rather than a directory. The permissions on the file itself and its directory were fine. When a new terminal was loaded the file could be run from anywhere. However, git gave an identical error message.

So as well as looking for folders on the path with incorrect permissions I suggest anyone else with this problem also checks that the path points only to folders and not to files.

沫雨熙 2024-10-05 20:29:04

安装 Foundation 后在 OSX 中发现同样的问题。

我的 .bash_profile 中的违规行是格式错误的基础导出路径。我没有删除该行末尾的 /foundation,因此它指向一个二进制文件,而不是文件夹。

只是修好了它,重新加载终端,一切又恢复正常了。

Found the same problem in OSX after installing Foundation.

The offending line in my .bash_profile was a malformed foundation export path. I didn't remove the /foundation at the end of the line, so it was pointing to a binary file, not a folder.

Just fixed it, reloaded Terminal and everything worked again.

橙幽之幻 2024-10-05 20:29:04

我也遇到了同样的问题,这是一个格式错误的 .bash_profile 行。

当我安装 WP_CLI 时,它将以下行添加到我的 .bash_profile 中,

export PATH=/root/.wp-cli/bin:$PATH

我必须对其进行轻微的更改。我正在使用 CentOs 来解决这个问题。

export PATH=$PATH:/root/.wp-cli/bin

这解决了我的问题。

I had the same problem too, and this was a badly formatted .bash_profile line.

When I installed WP_CLI, it added the following line to my .bash_profile

export PATH=/root/.wp-cli/bin:$PATH

I had to make a slight change for it. I'm using CentOs for that matter.

export PATH=$PATH:/root/.wp-cli/bin

This fixed my problem.

谈情不如逗狗 2024-10-05 20:29:04

Git 还有一个内置的别名命令。

别名命令示例:

git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch
git config --global alias.lola 'log --graph --decorate --pretty=oneline --abbrev-commit --all'

Git also has a built in alias command.

Example alias commands:

git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch
git config --global alias.lola 'log --graph --decorate --pretty=oneline --abbrev-commit --all'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文