git branch (分支操作)
git branch <new branch> 新建分支 不切换
git branch 查看本地所有分支
git branch -r 查看远程所有分支
git branch -a 查看本地和远程的所有分支
git branch -m <new branch> 修改当前分支名
git branch -m <local branch> <new branch> 修改不是当前分支的分支名
git branch -d <local branch> 删除本地分支(即将删除的分支已经合并到当前分支)
git branch -D <local branch> 删除本地分支(即将要删除的分支没有合并到当前分支)
git push origin --delete <remote branch> 删除远程分支
git branch -v 查看本地各、分支最后的提交信息
git checkout(用于切换分支或恢复工作树文件)
git checkout <local branch> 切换本地分支
git checkout -b <new branch> 新建分支并切换到该分支
git checkout -b <new branch> origin/<remote branch> 把远程分支拉取到本地,作为新的分支
git checkout . 把当前目录所有修改的文件恢复成未修改时
git checkout --<file name> 恢复当前某个文件
git fetch
git fetch 查看远程版本的更新,取到本地
git fetch -p 查看远程已删除之后的分支
tag
git tag -l查看本地tag
git ls-remote -t 查看远程tag
git tag -d tag-name 删除本地tag
git push origin :refs/tags/tag-name 删除远程tag
git fetch origin --prune-tags 最后远程拉取远程tags
git push --tag push本地tag到远程
git reset (撤销commit操作)
git reset --soft HEAD^ 仅是撤销commit记录,所有改动都保留(工作区和暂存区)
git reset --mixed HEAD^ 撤销commit记录,所有改动都保留在工作区
git reset --hard HEAD^ 不仅是撤销commit记录,所有改动都被撤销(工作区和暂存区)
git rev-parse HEAD 获取本次commit后的commit id