找到一个名称的交换文件

Mal*_*loc 63 git github

当我尝试将我的分支与远程分支合并时:

git merge feature/remote_branch
Run Code Online (Sandbox Code Playgroud)

我收到了这条消息:

E325: ATTENTION
Found a swap file by the name ".git/.MERGE_MSG.swp"
          owned by: xxxxxx   dated: Mon Nov 12 23:17:40 2012
         file name: ~xxxxxx/Desktop/My-ios-App/.git/MERGE_MSG
          modified: YES
         user name: xxxxxx   host name: unknown-b8-8d-12-22-27-72.lan
        process ID: 1639
While opening file ".git/MERGE_MSG"
             dated: Tue Nov 13 14:06:48 2012
      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 .git/MERGE_MSG"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".git/.MERGE_MSG.swp"
    to avoid this message.

Swap file ".git/.MERGE_MSG.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
Run Code Online (Sandbox Code Playgroud)

怎么处理这个?

tro*_*foe 72

看起来你有一个打开git commitgit merge继续,编辑器仍然打开编辑提交消息.

两种选择:

  1. 找到会话并完成它(最好).
  2. 删除.swp文件(如果你确定其他git会话已经消失).

评论澄清:

  • 会议是编辑会话.
  • 您可以.swp通过:sw在编辑会话中输入命令来查看正在使用的内容,但通常它是与您正在使用的文件位于同一目录中的隐藏文件,带有.swp文件后缀(即~/myfile.txt可能~/.myfile.txt.swp).

  • 如何找到这个.swp文件? (9认同)
  • 如何找到"会话" - 这是什么意思? (9认同)

小智 9

2022 年 2 月更新:

移除.MERGE_MSG.swp以避免E325: ATTENTION

rm .MERGE_MSG.swp
Run Code Online (Sandbox Code Playgroud)

通常.example.swp文件并不重要。

另外,通常.example.swp文件是在原始文件的同一目录中创建的。然后,您无法在终端上列出.example.swp文件ls。您需要使用llls -a命令来列出.example.swp终端上的文件。


Rob*_*air 8

接受的答案未提及如何删除.swp文件。

出现提示时,按“ D”,它将删除它。

就我而言,在我按下D之后,它保留了最新保存的版本,并删除了创建的.swp,因为我错误地退出了VIM

  • 谢谢您-无论是谁在bash程序中进行制作的,都应加上以下注释:“如果您想保留所做的更改,并删除旧的更改,请按D” (2认同)

Abd*_*man 6

.MERGE_MSG.swp 在你的 git 中打开,你只需要删除这个 .swp 文件。就我而言,我使用了以下命令,效果很好。

rm .MERGE_MSG.swp
Run Code Online (Sandbox Code Playgroud)