十年匠心定制 · 商业建站与技术教学双线并行 咨询热线:400-886-1026 service@lmnt.cn
ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

Git 下载与安装,sh.exe 调用 Windows 上的 .sh 格式 Shell 文件

Git 下载与安装,sh.exe 调用 Windows 上的 .sh 格式 Shell 文件 Git 官方文档教程地址Git - BookGit V2.55 安装步骤https://gitee.com/wangmx1993/material/blob/master/doc/csdn/md/Git2.55%E5%AE%89%E8%A3%85.mdGit 2.32 下载 与 Win 10 安装1、进入 Git 官网https://git-scm.com/建议使用 Chrome 浏览器Firefox 容易下载失败。2、安装与普通的软件没有什么区别都是安装步骤走即可特殊地方截图说明其余全部默认即可。验证 win 10 是否安装成功1、随便哪个目录下右键能看到 git 选项即表示安装成功通过 Git Bash 可以来执行 git 命令。CentOS 7.5 yum 安装 Git1、系统发行版本为 CentOS 7.5、内核版本为 3.10[rootlocalhost ~]# uname -a Linux localhost.localdomain 3.10.0-862.9.1.el7.x86_64 #1 SMP Mon Jul 16 16:29:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux [rootlocalhost ~]# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.5.1804 (Core) Release: 7.5.1804 Codename: Core [rootlocalhost ~]#2、先使用 yum list 命令查询 看有无可直接安装的源如下所示有一个 1.8.3 的版本[rootlocalhost ~]# yum list git 已加载插件fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast Loading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 可安装的软件包 git.x86_64 1.8.3.1-14.el7_5 updates [rootlocalhost ~]#3、接着便可以使用 yum install git.x86_64 安装它。[rootlocalhost ~]# yum install git.x86_64 已加载插件fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.zju.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 mysql-connectors-community | 2.5 kB 00:00:00 mysql-tools-community ........................... 已安装: git.x86_64 0:1.8.3.1-14.el7_5 作为依赖被安装: libgnome-keyring.x86_64 0:3.12.0-1.el7 perl-Error.noarch 1:0.17020-2.el7 perl-Git.noarch 0:1.8.3.1-14.el7_5 perl-TermReadKey.x86_64 0:2.30-20.el7 rsync.x86_64 0:3.1.2-4.el7 完毕 [rootlocalhost ~]#查看所有可用命令1、安装完成后直接输入git 命令可以查看它所有的命令使用 git --version 可以查看 git 版本。2、如下所示无论是在 linux 还是 windows 都是一样的。[rootlocalhost ~]# git usage: git [--version] [--help] [-c namevalue] [--exec-path[path]] [--html-path] [--man-path] [--info-path] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dirpath] [--work-treepath] [--namespacename] command [args] 最常用的 git 命令有 add 添加文件内容至索引 bisect 通过二分查找定位引入 bug 的变更 branch 列出、创建或删除分支 checkout 检出一个分支或路径到工作区 clone 克隆一个版本库到一个新目录 commit 记录变更到版本库 diff 显示提交之间、提交和工作区之间等的差异 fetch 从另外一个版本库下载对象和引用 grep 输出和模式匹配的行 init 创建一个空的 Git 版本库或重新初始化一个已存在的版本库 log 显示提交日志 merge 合并两个或更多开发历史 mv 移动或重命名一个文件、目录或符号链接 pull 获取并合并另外的版本库或一个本地分支 push 更新远程引用和相关的对象 rebase 本地提交转移至更新后的上游分支中 reset 重置当前HEAD到指定状态 rm 从工作区和索引中删除文件 show 显示各种类型的对象 status 显示工作区状态 tag 创建、列出、删除或校验一个GPG签名的 tag 对象 命令 git help -a 和 git help -g 显示可用的子命令和一些指南。参见 git help 命令 或 git help 指南 来查看给定的子命令帮助或指南。 [rootlocalhost ~]# git --version git version 1.8.3.1 [rootlocalhost ~]#环境配置-设置账户与邮箱1、因为 Git 是分布式版本控制系统所以约定本地设置账号(名字)和 Email 地址作为提交用户信息因为邮箱地址通常都是唯一的。2、注意这个账号与邮箱地址要求是 github 或者 gitee 等平台的登录账号或邮箱可以随意定义它们并不会用于服务器认证校验只有在 push 代码到平台的时候才会真正的提示输入平台的登录账号与密码正确之后才能推送成功。1git config --global user.name xxxx 设置用户名2git config --global user.email xxxx 设置邮箱3git config user.name 查看用户名4git config user.email 查看邮箱5git config --global user.name xxxx修改用户名直接覆盖即可6git config --global user.email xxxxxxx.com 修改邮箱直接覆盖即可7git config --list 查看所有配置8git config --global --unset user.name 删除用户名9 git config --global --replace-all user.name new name 替换所有的旧 user.name 属性的值2、注意 git config 命令的 --global 参数用了这个参数表示这台机器上所有的 Git 仓库都会使用这个配置当然也可以对某个仓库指定不同的用户名和 Email 地址。AdministratorSC-201707281232 MINGW64 /e/GitRepository $ git config --list core.symlinksfalse core.autocrlftrue core.fscachetrue color.diffauto color.statusauto color.branchauto color.interactivetrue help.formathtml rebase.autosquashtrue http.sslcainfoD:/Git/mingw64/ssl/certs/ca-bundle.crt http.sslbackendopenssl diff.astextplain.textconvastextplain filter.lfs.cleangit-lfs clean -- %f filter.lfs.smudgegit-lfs smudge -- %f filter.lfs.processgit-lfs filter-process filter.lfs.requiredtrue credential.helpermanager user.namewangmaoxiong user.email22xxxx61750qq.comGit 记住密码与重置密码1、有的时候往 github 或者 gitee 上推送代码的时候一不小心输错了账号或者密码时则后续推送时一直提示认证错误fatal: Authentication failed for https://gitee.com/......2、此时需要执行命令让 git 取消记住密码然后再推送时即可重新输入密码git config --system --unset credential.helper取消设置凭证即取消记住密码执行之后以后每次 push 时都需要手动输入账号密码git config --global credential.helper store设置凭证助手即记住密码只要输入一次账号密码后后续 push 时就不会要求再输入sh.exe 调用 Windows 上的 .sh Shell文件1、git 安装中可以勾选修改环境变量这样它就会自动修改环境变量以后在 cmd 中便可以直接调用 git 了但是它默认设置的是安装目录下的 cmd 目录。2、在 bin 目录下有一个非常好用的工具sh.exe可以在 Windows 系统上帮助运行 .sh 格式的 Shell 脚本文件默认情况下 .sh 在 windows 系统上是无法直接执行的Linux系统上才可以直接运行但是依靠 git 的 sh.exe 程序则可以执行在 windows 系统上执行 .sh 文件。3、当然可以不用配置 sh.exe 的环境变量使用的时候使用全路径即可但是为了方便也可以配置在环境变量中这样以后可以直接调用。D:\tempD:\software2024\Git\bin\sh.exe D:\temp\test.sh 请输入分数[0,100]:50 不及格 D:\temp3、如下所示正常情况下 windows 上启动 /关闭 Tomcat 用的是 .bat 文件.sh 文件是无法执行的Linux 上则刚好相反因为 .sh 文件本身就是为 Linux 系统准备的现在安装了 git 之后就可以使用 bin目录下的 sh.exe 程序在 windows 上也能执行 .sh 文件了配置了 sh.exe 的环境变量后则可以直接输入 sh 调用了。
返回列表