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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jitcor

觉得有用,不赏点?

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值