Git:使用适用于 Windows 的 GitHub 客户端在 PATH 中安装 Git [英] Git: Installing Git in PATH with GitHub client for Windows

查看:25
本文介绍了Git:使用适用于 Windows 的 GitHub 客户端在 PATH 中安装 Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用适用于 Windows 的 GitHub 客户端时,如何在 PATH 中安装 Git?

How do I install Git in my PATH when using the GitHub client for Windows?

我遇到了错误,因为显然 Git 没有安装在 PATH 中.例如,使用 Atom,尝试安装 Linter 插件会出现此错误:

I'm running into errors because apparently Git is not installed in PATH. For example, using Atom, trying to install the Linter plugin gives this error:

npm ERR! not found: git
npm ERR! 
npm ERR! Failed using git.
npm ERR! This is most likely not a problem with npm itself.
npm ERR! Please check if you have git installed and in your PATH.

Windows 版 GitHub 在安装时是否安装 Git?(它必须,否则它如何使用 Git?)我不想双重安装它......那么我如何将已经存在的 Git 添加到 PATH 中?

Does GitHub for Windows install Git when it installs? (It must, otherwise how does it use Git?) I don't want to double-install it... so how do I just add the Git that's already there to PATH?

推荐答案

GitHub for Windows 确实安装了它自己的 Git 版本,但它没有将它添加到 PATH 变量中,这是很容易做到.以下是有关如何操作的说明:

GitHub for Windows does indeed install its own version of Git, but it doesn't add it to the PATH variable, which is easy enough to do. Here's instructions on how to do it:

  1. 获取 Git URL

我们需要获取您计算机的 Git cmd 目录的 url.Git 位于此处:

We need to get the url of the Git cmd directory your computer. Git is located here:

C:Users<user>AppDataLocalGitHubPortableGit_<guid>cmdgit.exe

因此,在您的计算机上,将 替换为您的用户,然后找出 对您的计算机而言是什么.(guid 可能会在每次 GitHub 更新 PortableGit 时发生变化,但他们正在研究解决方案.)

So on your computer, replace <user> with your user and find out what the <guid> is for your computer. (The guid may change each time GitHub updates PortableGit, but they're working on a solution to that.)

将其复制并粘贴到命令提示符中(右键单击 > 粘贴以粘贴到终端中)以验证它是否有效.您应该会看到列出常见 Git 命令的 Git 帮助响应.如果看到系统找不到指定的路径,那么就是URL不对.确定后,使用以下格式创建指向目录的链接:

Copy it and paste it into a command prompt (right-click > paste to paste in the terminal) to verify that it works. You should see the Git help response that lists common Git commands. If you see The system cannot find the path specified. Then the URL isn’t right. Once you have it right, create the link to the directory using this format:

;C:Users<user>AppDataLocalGitHubPortableGit_<guid>cmd

(注意:最后是cmd,不再是cmdgit.exe!)

(Note: cmd at the end, not cmdgit.exe anymore!)

在我的系统上,就是这个,你的会不一样:

On my system, it’s this, yours will be different:

;C:UsersrentonAppDataLocalGitHubPortableGit_7eaa494e16ae7b397b2422033as45d8ff6ac2010cmd

  • 编辑 PATH 变量

    导航到环境变量编辑器(说明)并找到Path变量在系统变量"部分.单击 Edit... 并将 Git 的 URL 粘贴到该字符串的末尾.节省!将其拉入记事本进行编辑可能更容易,只需确保在粘贴 URL 之前输入 一个 分号.如果它不起作用,那可能是因为这条路径在某处有一个空格(分号周围应该没有空格)或最后有一个分号(分号应该只分隔 URL,在开头或结尾没有分号)细绳).

    Navigate to the Environmental Variables Editor (instructions) and find the Path variable in the "System Variables" section. Click Edit… and paste the URL of Git to the end of that string. Save! It might be easier to pull this into Notepad to do the edit, just make sure you put one semicolon before you paste in the URL. If it doesn't work it’s probably because this path got messed up either with a space in there somewhere (should be no spaces around the semicolon) or a semicolon at the end (semicolons should only separate URLs, no semicolon at beginning or end of string).

    如果它有效,你应该能够关闭 &重新打开一个终端并输入 git ,它会给你同样的 git 帮助文件.然后安装 Linter 应该可以工作.(Atom > 文件 > 设置 > 包 > Linter)

    If it worked, you should be able to close & reopen a terminal and type git and it will give you that same git help file. Then installing the Linter should work. (Atom > File > Settings > Packages > Linter)

    这篇关于Git:使用适用于 Windows 的 GitHub 客户端在 PATH 中安装 Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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