Git常见命令
Git 常见命令
基础流程
git status
git add <file>
git add .
git commit -m "message"分支操作
git branch
git branch <name>
git switch <name>
git switch -c <name>
git merge <name>
git branch -d <name>
git branch -D <name>远程仓库
git remote add origin <url>
git remote -v
git pull origin main
git push origin main
git push -u origin main回退与撤销
git restore <file>
git restore --staged <file>
git reset --hard HEAD^
git reset --hard <commit>暂存区与工作区
git diff
git log --oneline --graph保存与恢复(stash)
git stash push -m "msg"
git stash list
git stash apply stash@{0}
git stash pop
git stash drop stash@{0}标签
git tag v1.0
git tag -a v0.1 -m "v0.1 released"
git show v1.0
git tag -d v0.1
git push origin v1.0
git push origin --tags
git push origin -d v0.1