前言:
演示使用操作系统:windows11
git的下载与安装
登录git官网:https://git-scm.com/
![](https://i-blog.csdnimg.cn/blog_migrate/ad6ac1821099dfb6f30804528763dc04.png)
点击下载
![](https://i-blog.csdnimg.cn/blog_migrate/e8d06ca0e699b1716043008722b69905.png)
选择操作系统
![](https://i-blog.csdnimg.cn/blog_migrate/e34c0739a72ba032a9d4e8b6e2f5d1d6.png)
根据操作系统选择下载安装程序
![](https://i-blog.csdnimg.cn/blog_migrate/8c41b277bd84b7aa163ed3da6ee3c56b.png)
运行安装程序进行安装
此部分非本文终点,不做详细介绍,如安装过程出现问题,可以尝试参考网络其他资料解决。
git的配置
在空白处右键选择Git Bash Here
![](https://i-blog.csdnimg.cn/blog_migrate/39697f07f6f17331dbf710ee81017787.png)
配置用户名
使用git config --global user.name "your username" 配置用户名,其中 "your username" 替换为自己的用户名
配置邮箱
使用git config --global user.email "your email address"配置邮箱,其中 "your email address" 替换为自己的邮箱
查看配置是否成功
使用git config --list --global查看,配置成功,显示如下信息:
![](https://i-blog.csdnimg.cn/blog_migrate/d18b5a86f0f4f9ef643a19accb3c80e9.png)
git基本指令
初始化仓库
git init
设置提交代码时的用户信息
git config [--global] user.name "[your username]"
git config [--global] user.email "[your email address]"
添加指定文件到暂存区
git add [file1] [file2] ...
将当前目录的所有文件添加到暂存区
git add .
提交暂存区到仓库
git commit -m [message]
提交暂存区指定文件到仓库
git commit [file1] [file2] ... -m [message]
增加一个新的远程仓库并命名
git remote add [name] [url]
上传本地指定分支到远程仓库
git push [remote] [branch]