Git 常用命令速查手册
Git 是目前最流行的分布式版本控制系统,以下是日常开发中最常用的命令整理。
基础操作
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| git init
git clone <url>
git status
git add <file> git add .
git commit -m "commit message"
git log --oneline --graph
|
分支管理
1 2 3 4 5 6 7 8 9 10 11
| git branch -a
git checkout -b <branch-name>
git merge <branch-name>
git branch -d <branch-name>
|
远程仓库操作
1 2 3 4 5 6 7 8 9 10 11
| git remote -v
git push origin <branch-name>
git pull origin <branch-name>
git fetch origin
|
撤销操作
1 2 3 4 5 6 7 8
| git checkout -- <file>
git reset HEAD <file>
git reset --hard <commit-id>
|
实用技巧
1 2 3 4 5 6 7 8 9
| git stash git stash pop
git log -p <file>
git tag -a v1.0 -m "version 1.0"
|
💡 提示: 建议将常用命令设置为 Git alias,提高效率!
更多 Git 进阶用法将在后续文章中分享,敬请关注!