Git 撤回本地Commit
應(yīng)用場景之一如下:本地提交的一個文件過大(超過200M)杨伙,然后push到Gitee受限磺浙,不得不回撤提交并刪除或者壓縮過大的文件
$ git log
查看提交記錄
commit a1181ff4a326543b544bf5ec4074bf5ac43fd1e5 (HEAD -> develop_tabBar)
Author: Thomas <qq717966365@163.com>
Date: Mon Aug 19 17:46:04 2019 +0800
【我想撤回的記錄】
commit d2469d4def16daeabec2d714551db28c013b7240 (origin/develop_tabBar)
Author: Thomas <qq717966365@163.com>
Date: Mon Aug 19 17:13:21 2019 +0800
[我是一次提交]
git reset --soft|--mixed|--hard {commit_id}
- --mixed
會保留源碼,只是將git commit和index 信息回退到了某個版本. - --soft
保留源碼,只回退到commit信息到某個版本.不涉及index的回退,如果還需要提交,直接commit即可. - --hard
源碼也會回退到某個版本,commit和index 都會回退到某個版本.(注意,這種方式是改變本地代碼倉庫源碼)
$git reset --soft a1181ff4a326543b544bf5ec4074bf5ac43fd1e5