【git】在删除某一commit时出现error: The following untracked working tree files would be overwritten by checkou

问题:

error: The following untracked working tree files would be overwritten by checkout:
        test1/.gitignore
        test1/matplotlib.plt.subplot.py
        test1/sklearn.datasets.py
        test1/test1.py
        test1/test2.py
        test1/test3.py
Please move or remove them before you switch branches.
Aborting
error: could not detach HEAD

解决办法:查看缓冲区:git status

发现有个untracked file 没有路径的test1文件

然后强制抹杀 git  clean -dfx

这下再按照正常删除commit操作就可以顺利进行了

 git rebase -i 7bd2d14(要删除commit之前提交的commit的commit_id)

进入编辑模式(键盘  i  ),修改pick为drop(删除此次commit)

保存退出(键盘 ESC  :wq)

更新远程和本地记录  git push origin master -f
 

提醒:删除commit后code就会滚回上一个version,而不会保留此次commit的内容,所以code里涉及个人隐私的还是在本地改好再上传,有更好的办法欢迎私信评论!!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值