# Git 常用命令速查

> 发布时间: 2026-08-02 18:25

# Git

## 初始配置

```
//设置用户名
git config user.name "name"
//设置用户邮箱
git config user.email XX@XX.xom
//设置代理
git config http.proxy Ip:Port
```

## 提交

```
//添加
git add .
//提交到本地库
git commit -m "描述"
//推送到远端
git push
//拉取
git pull
//查询差异
git status
git diff
//分支管理
git branch
//用于在远程仓库的操作
git remote add main git@github.com:xx/xx.git 
//全回退
git reset HEAD^
//指定文件回退
git reset HEAD^ [文件]
//回退n个版本
git reset HEAD^n
//回退到指定版本
git reset 版本号
//git pull无法拉取时的操作
git fetch --all
git reset --hard [库名]
git pull
```