问题:
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里涉及个人隐私的还是在本地改好再上传,有更好的办法欢迎私信评论!!