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

你可能感兴趣的:(git,tool)