error: Your local changes to the following files would be overwritten by merge:

$ git stash pop
error: Your local changes to the following files would be overwritten by merge:
       
        uyi/test.py
Please commit your changes or stash them before you merge.
Aborting
The stash entry is kept in case you need it again.
在切换分支前,git stash,切换分支后执行git stash pop报错,解决方法如下

//把列出的文件通通 git add /git commit
//如果刚才commit的文件你需要push就git pull/git push上去
//如果不想push,就执行git reset --hard HEAD^ 来撤销刚才的add和commit

以上,就可以执行 git stash pop啦!

命令拓展:

//执行commit后,还没执行push时,想要撤销这次的commit
git reset --soft HEAD^
//如果想要连着add也撤销的话,--soft改为--hard(删除工作空间的改动代码)。
git reset --hard HEAD^

HEAD^ 表示上一个版本,即上一次的commit,也可以写成HEAD~1
如果进行两次的commit,想要都撤回,可以使用HEAD~2

如果commit注释写错了,先要改一下注释,有其他方法也能实现,如:

git commit --amend
这时候会进入vim编辑器,修改完成你要的注释后保存即可。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值