Found a swap file by the name “~/xdf/daxue-ui-tiku-manage/.git/.MERGE_MSG.swp“

git pull 出现如下报错:

Found a swap file by the name "~/xdf/daxue-ui-tiku-manage/.git/.MERGE_MSG.swp"
          owned by: yangshaotong   dated: 五  9 24 14:16:05 2021
         file name: ~yangshaotong/xdf/daxue-ui-tiku-manage/.git/MERGE_MSG
          modified: YES
         user name: yangshaotong   host name: yangshaotongdeMacBook-Pro.local
        process ID: 58264
While opening file "/Users/yangshaotong/xdf/daxue-ui-tiku-manage/.git/MERGE_MSG"
             dated: 五  9 24 17:34:35 2021
      NEWER than swap file!

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r /Users/yangshaotong/xdf/daxue-ui-tiku-manage/.git/MERGE_MSG"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/Users/yangshaotong/xdf/daxue-ui-tiku-manage/.git/.MERGE_MSG.
swp"
    to avoid this message.

Swap file "~/xdf/daxue-ui-tiku-manage/.git/.MERGE_MSG.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort: 
Swap file "~/xdf/daxue-ui-tiku-manage/.git/.MERGE_MSG.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

当前选择A或Q之后,不管是执行pull或者push都会报错,如下:Found a swap file by the name “~/xdf/daxue-ui-tiku-manage/.git/.MERGE_MSG.swp“

解决方案:

第一步: 保证要提交的代码不丢

1、拷贝当前分支

git checkout -b 拷贝分支名

2、切换到其他分支准备删除当前分支

git checkout 其他分支(如:master)

3、删除刚才已被备份的分支

git branch -D 已被备份的分支

4、基于master或其他可靠的分支创建新分支

git checkout -b 新分支

5、把备份的分支合并到新分支(之前没有提交的代码就回来了)

git chirry-pick 备份分支名

第二步: 修复问题
删除错误提示中的文件即可

sudo rm -rf /Users/yangshaotong/xdf/daxue-ui-tiku-manage/.git/.MERGE_MSG.swp
上一篇:泪目了,记录一下改了一天的bug


下一篇:CentOS------Redis远程连接可视化工具Rdis Desktop Manage