Git 实用技巧

Git 实用技巧

git 命令行查看提交记录

git log —graph —all -p —decorate —abbrev-commit
 —graph 以图像显示
 —all 显示所有分支
 —decorate 显示所有分支名和 tag 名
 —abbrev-commit 只显示简短的 hash 值
 -p 显示提交的文件差异

从某一个提交开始重置所有提交

git rebase -i hash

获取所有远程tag

git fetch origin -t

推送所有本地新tag

git push origin --tags                                                                       

更新tag命令

(将 orgin tag 更新至 new orign)

git fetch origin --t && git push new-origin --tags && git tag -l | xargs git tag -d && git fetch

删除所有本地tag

git tag -l | xargs git tag -d

删除所有特定tag并推送

git tag | grep ZICE | xargs -n 1 git push --delete origin  

获取所有远程tag

git fetch

Git如何删除版本库中的一个提交

非 master 分支,未 merge 仅取消最后一次提交

1. git reset --hard HEAD~1
2. git push --force

非 master 分支,未 merge 删除过去的某一次提交

git rebase -i 'hash'

Git 如何删除本地所有未提交的更改

git checkout -f &&  git clean -xdf && git pull
posted @ 2019-11-19 15:28  二面妖精  阅读(191)  评论(0)    收藏  举报