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