Git使用記錄(刪除某次提交)

$ git log --pretty=format:"%h %s" HEAD~5..HEAD
a2c1284 add
2cab9eb add
bac4b00 opt
$ git rebase -i HEAD~3
hint: Waiting for your editor to close the file... libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: cHRM chunk does not match sRGB
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
interactive rebase in progress; onto 92316a4
Last commands done (4 commands done):
   drop bac4b00 opt
   pick 2cab9eb add
No commands remaining.
You are currently rebasing branch 'master' on '92316a4'.

Untracked files:
        src/xxxxx/.vs/
        src/xxxxx/Debug/

nothing added to commit but untracked files present
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

    git commit --allow-empty

Otherwise, please use 'git reset'
Could not apply 2cab9eb... add

在打開的編輯器裏將要刪除的commit提交前面的pick改成drop,保存並退出

$ git log --pretty=format:"%h %s" HEAD~3..HEAD
a2c1284 add

 

$ git push origin HEAD:master --force
Total 0 (delta 0), reused 0 (delta 0)
To https://xxxx/xxxx/xxx.git
 + 097f080...a2c1284 HEAD -> master (forced update)

參考

https://www.jianshu.com/p/2fd2467c27bb

https://blog.csdn.net/u013553529/article/details/88087047

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章