git进阶

182 阅读1分钟

gitignore 不起作用

git rm -r --cached .
git add .
git commit -m 'update .gitignore'

版本回退

git add 前回退 git checkout -- file
git add 后回退:git reset HEAD file   git checkout --file
git commit 回退: git reset -hard HEAD^
git reset --hard HEAD^        回退到上个版本
git reset --hard HEAD~3       回退到前3次提交之前,以此类推,回退到n次提交之前
git reset --hard commit_id    退到/进到 指定commit的sha码

打标签

轻量标签(lightweight): git tag [tagname]
附注标签(annotated): git tag -a [tagname] -m 'version 1.0.1'
删除本地tag: git tag -d [tagname]
删除远程tag: git push origin :refs/tags/[tagname]
推送标签: git push origin [tagname]
推送所有标签: git push origin --tags