Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Found a swap file by the name

When I try to merge my branch with a remote branch:

git merge feature/remote_branch 

I got this message:

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: 

How to deal with this?

like image 882
Malloc Avatar asked Nov 13 '12 13:11

Malloc


People also ask

How do I resolve a swap file by name?

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 ".

Where do I find .SWP files?

To find out if . swp exist: With the target file open in vim, execute :sw to get current swap file. Check the directory that the current swap file is contained in.

What is a .SWP file in Linux?

An SWP file is a swap file created by the Vi text editor or one of its variants, such as Vim (Vi iMproved) and gVim. It stores the recovery version of a file being edited in the program. SWP files also serve as lock files, so no other Vi editing session can concurrently write to the currently-open file.


1 Answers

Looks like you have an open git commit or git merge going on, and an editor is still open editing the commit message.

Two choices:

  1. Find the session and finish it (preferable).
  2. Delete the .swp file (if you're sure the other git session has gone away).

Clarification from comments:

  • The session is the editing session.
  • You can see what .swp is being used by entering the command :sw within the editing session, but generally it's a hidden file in the same directory as the file you are using, with a .swp file suffix (i.e. ~/myfile.txt would be ~/.myfile.txt.swp).
like image 174
trojanfoe Avatar answered Sep 17 '22 22:09

trojanfoe