Git 常用命令速查表
| 场景 | 命令 |
|---|---|
| 初始化仓库 | git init |
| 克隆仓库 | git clone <url> |
| 查看状态 | git status |
| 添加文件 | git add . |
| 提交 | git commit -m "msg" |
| 推送到远程 | git push origin main |
| 拉取更新 | git pull |
| 查看分支 | git branch -a |
| 切换分支 | git checkout -b new-branch |
| 合并分支 | git merge branch-name |
| 撤销工作区 | git checkout -- file |
| 撤销暂存区 | git reset HEAD file |
| 撤销提交(保留修改) | git reset --soft HEAD~1 |
| 暂存当前工作 | git stash |
| 查看日志 | git log --oneline --graph |