root 可以使用 Git,但任何其他帐户:-bash: git: command not find

发布于 2024-12-09 21:24:23 字数 109 浏览 3 评论 0原文

.bashrc(在用户帐户上):

export PATH=/usr/bin:$PATH

如何让 Git 在 Root 以外的帐户上工作?

.bashrc (on user account):

export PATH=/usr/bin:$PATH

How can I get Git to work on accounts other than Root?

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

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

发布评论

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

评论(2

惯饮孤独 2024-12-16 21:24:24

作为 root,执行 which git

[ 08:45 root@host ~ ]# which git
/usr/local/bin/git

然后获取返回的路径(/usr/local/bin/git,或其他)并添加它(除了最后一个 /git 部分)到用户 .bashrc 的那一行,如下所示:

[ 08:45 jon@host ~ ]$ vi ~/.bashrc

export PATH=/usr/bin:$PATH:/usr/local/bin

然后 source .bashrc 文件:

[ 08:45 jon@host ~ ]$ source ~/.bashrc

另外,请确保该文件可供所有人执行(不仅仅是root) 和 chmod 755 所以它看起来像这样:

[ 08:45 jon@host ~ ]$ sudo chmod 755 /usr/local/bin/git
[ 08:45 jon@host ~ ]$ ls -l /usr/local/bin/git
-rwxr-xr-x@ 1 root  root   613B Jan 12 15:26 git

As root, do which git:

[ 08:45 root@host ~ ]# which git
/usr/local/bin/git

then take the path that is returned (/usr/local/bin/git, or whatever) and add it (except for the last /git part) to that line of the users .bashrc like so:

[ 08:45 jon@host ~ ]$ vi ~/.bashrc

export PATH=/usr/bin:$PATH:/usr/local/bin

Then source the .bashrc file:

[ 08:45 jon@host ~ ]$ source ~/.bashrc

Also, make sure the file is executable by all (not just root) with chmod 755 so it looks like this:

[ 08:45 jon@host ~ ]$ sudo chmod 755 /usr/local/bin/git
[ 08:45 jon@host ~ ]$ ls -l /usr/local/bin/git
-rwxr-xr-x@ 1 root  root   613B Jan 12 15:26 git
站稳脚跟 2024-12-16 21:24:24

通过在我的deploy.rb 文件中添加以下条目解决了我的问题:
set :local_scm_command, :default

请参阅此链接中的条目:
https://github.com/capistrano/capistrano/wiki/2 .x-From-The-Beginning

“顺便说一句:您可能安装了 subversion(或您正在使用的任何 SCM),但安装的位置不在标准路径中。(标准路径通常是/bin:/usr/bin:/usr/sbin。)如果是这种情况,Capistrano 将无法找到您的 svn 可执行文件,您需要明确告诉 Capistrano 它在哪里,为此,请设置。 :scm_command 到它所在的远程服务器上的路径,但是,如果您这样做,您可能会发现 Capistrano 在这种情况下无法再在本地服务器上找到该命令; :local_scm_command 到 :default (或本地服务器上的显式路径)。”

My problem was solved by making this entry in my deploy.rb file:
set :local_scm_command, :default

Please see the entry in this link:
https://github.com/capistrano/capistrano/wiki/2.x-From-The-Beginning

"A quick aside: you might have subversion (or whatever SCM you’re using) installed, but in a place that’s not in the standard path. (The standard path is typically /bin:/usr/bin:/usr/sbin.) If this is the case, Capistrano won’t be able to find your svn executable, and you’ll need to tell Capistrano explicitly where it is. To do so, set :scm_command to the path on the remote servers where it is located. If you do this, though, you might discover that Capistrano can no longer find the command on the local server; in that case, set :local_scm_command to :default (or to the explicit path on your local server)."

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文