【git】在分支中执行add,commit之后,代码丢失

  使用git来管理自己的代码,在分支中执行命令add 和 commit之后,使用git push推送到了远程仓库,但是从远程仓库看的时候,并没有发现更新的代码。切换到主分支重新执行了add,commit,push 3个命令,也远程仓库也没有变化。晚上太晚了,就没有再解决。

  第二天发现所有的代码丢失了。在master分之下,无法切换到Taotao-A 分支。

问题

fxq@DESKTOP-ASCGQPD MINGW64 /g/Java/Taotao (master)
$ git checkout Taotao-A
fatal: Unable to create 'G:/Java/Taotao/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.

  重新创建新的分支,同样出现上述问题,无法切换分支;


解决方案

rm -f ./.git/index.lock 

 

  切换成功,进入Taotao-A 分支,之后代码就恢复了。再见

评论 18
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值