Swap file found by name

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

git merge feature/remote_branch 

I received 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?

+61
git github
Nov 13 '12 at 13:39
source share
4 answers

It looks like you have open git commit or git merge open, and the editor is still open for editing the commit message.

Two options:

  1. Find the session and end it (preferred).
  2. Delete the .swp file (if you are sure that another git session is missing).

Clarification from comments:

  • A session is an editing session.
  • You can see that .swp is .swp used by typing :sw in an editing session, but it is usually a hidden file in the same directory as the .swp file used, with the suffix of the .swp file (i.e. ~/myfile.txt will be ~/.myfile.txt.swp ).
+69
Nov 13 '12 at 13:48
source share

The accepted answer does not mention how to delete the .swp file.

Press "D" when the prompt appears and it will be deleted.

In my case, after I pressed D, he left the last saved version unchanged and deleted the .swp, which was created because I got out of VIM incorrectly.

+8
Jul 13 '18 at 13:49
source share

I also had this error while trying to drag changes to a branch that was not created from the upstream branch from which I am trying to pull.

Eg - creates a new branch corresponding to the night-version upstream

 git checkout upstream/night-version -b testnightversion 

This creates a testmaster branch in local, which corresponds to the upstream master branch.

 git checkout upstream/master -b testmaster 

Now, if I try to pull the night-version changes in testmaster , the branch will result in this error.

 git pull upstream night-version //while I'm in `master` cloned branch 

I managed to solve this by going to the correct branch and pulling out the changes.

 git checkout testnightversion git pull upstream night-version // works fine. 
+1
Dec 02 '16 at 5:47
source share

.MERGE_MSG.swp is open in your git, you just need to delete this .swp file. In my case, I used the following command and it worked fine.

 rm .MERGE_MSG.swp 
0
Aug 25 '19 at 11:05
source share



All Articles