常用操作
git clone [repo_link]
git init -b [分支名]
git add [文件或者文件夹]
git commit -m "提交注释"
git commit --amend -m "提交注释"
git remote add [远程仓库名称] [远程仓库地址]
git remote rename|remove|set-url
git push -u [远程仓库名称] [分支名]
git push [远程仓库名称] [分支名]
git push
git pull [远程仓库名称] [分支名]
git fetch
git rm --cached [文件名]
git commit --amend --no-edit
查看操作
git status
git branch -all
git diff [文件名]
git diff --cached
git remote -v
git remote show
git log -[数字]
git log --oneline
git log --graph
git log --stat
git log --patch|-p
git log --after="2026-01-01" --before="2026-01-31"
git log --author=[作者]
git log --grep=["关键词"]
git reflog
git tag
git show [标签名] 查看某个特定标签的详细信息
还原文件
git checkout [文件名]
git log
git checkout [commit_id] [文件名]
git checkout [commit_id] [文件名]
分支管理
git branch [分支名]
git checkout -b [分支名]
git branch -d [分支名]
git branch -D [分支名]
git branch -m [原名称] [新名称]
git merge [被合并的分支名]
git rebase [分支名]
标签管理
git tag [标签名]
git tag -a [标签名] -m "提交注释"
git tag -a [标签名] [commit_id] -m "提交注释"
git push [远程仓库名称] [标签名]
git push [远程仓库名称] --tags
git tag -d [标签名]
git push [远程仓库名称] --delete [标签名]