# Git 常用命令 ## 基础操作 | 命令 | 说明 | |------|------| | `git init` | 初始化仓库 | | `git clone ` | 克隆仓库 | | `git add .` | 暂存所有更改 | | `git commit -m "msg"` | 提交更改 | | `git push` | 推送到远程 | | `git pull` | 拉取远程更新 | ## 分支管理 ```bash # 创建并切换到新分支 git checkout -b feature/new-feature # 查看所有分支 git branch -a # 合并分支 git merge feature/new-feature # 删除分支 git branch -d feature/new-feature ``` ## 撤销操作 - `git reset HEAD ` - 取消暂存 - `git checkout -- ` - 撤销文件修改 - `git revert ` - 撤销某次提交 - `git reset --soft HEAD~1` - 撤销最近一次 commit(保留更改)