在cmd 中遇到‘git’ 不是内部命令,如何解决(附带常用命令)

在windows 系统中,利用命令行进行 git 操作时,不是内部命令,那么,说明,你并没有安装GIT指令文件。

解决办法

第一步:从Git 官网,下载windows系统对应版本。

下载地址  https://git-scm.com/  

在网站中选择对应的版本,进行下载。

第二步:安装Git

一般使用默认设置即可:一路next,git安装完毕!

第三步:配置Git环境变量,确保在cmd 下能成功运行1.

1.找到git安装路径中bin的位置,如:D:Program FilesGitin

    找到git安装路径中git-core的位置,如:D:Program FilesGitlibexecgit-core;

    注:"D:Program FilesGit"是安装路径,可能与你的安装路径不一样,要按照你自己的路径替换"D:Program FilesGit"

2、右键“计算机”->“属性”->“高级系统设置”->“环境变量”->在下方的“系统变量”中找到“path”->选中“path”并选择“编辑”->将3.1种找到的bin和git-core路径复制到其中->保存并退出

    注:“path”中,每个路径之间要以英文输入状态下的分号“;”作为间隔


GIT 常用命令:

自己常用的一些Git命令

  • 显示command的helpgit help <command>
  • 将工作文件修改提交到本地暂存区git add <file>
  • 提交修改内容git commit "message"
  • 将本地主分支推到远程git push -u <remoteName> <localBrachName>
  • 克隆远程仓库git clone <url>
  • 初始化仓库git init
  • 创建仓库git remote add <remoteName> <url>
  • 删除远程仓库git remote rm <name>
  • 修改远程主机名git remote rename <remoteName> <newRemoteName>
  • 拉取远程仓库git pull <remoteName> <localBrachName>
  • 修改远程仓库git remote set-url --push <remoteName> <newUrl>
  • 获取远程仓库的更新git fetch <remoteName>
  • 获取远程仓库特定分支的更新git fetch <remoteName> <brachName>

原文地址:https://www.cnblogs.com/DeepRunning/p/9205892.html