Found a swap file by the name
Solution 1
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:
- Find the session and finish it (preferable).
- 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
).
Solution 2
Accepted answer fails to mention how to delete the .swp file.
Hit "D" when the prompt comes up and it will remove it.
In my case, after I hit D it left the latest saved version intact and deleted the .swp which got created because I exited VIM incorrectly
Solution 3
.MERGE_MSG.swp is open in your git, you just need to delete this .swp file. In my case I used following command and it worked fine.
rm .MERGE_MSG.swp
Solution 4
Feb, 2022 Update:
Remove .MERGE_MSG.swp
to avoid E325: ATTENTION
.
rm .MERGE_MSG.swp
Normally .example.swp
file is not important.
In addition, normally .example.swp
file is made in the same directory of the original file. Then, you cannot list .example.swp
files with ls
on terminal. You need to use ll
or ls -a
commands to list .example.swp
files on terminal.
Solution 5
I've also had this error when trying to pull the changes into a branch which is not created from the upstream branch from which I'm trying to pull.
Eg - This creates a new branch matching night-version
of upstream
git checkout upstream/night-version -b testnightversion
This creates a branch testmaster
in local which matches the master
branch of upstream.
git checkout upstream/master -b testmaster
Now if I try to pull the changes of night-version
into testmaster
branch leads to this error.
git pull upstream night-version //while I'm in `master` cloned branch
I managed to solve this by navigating to proper branch and pull the changes.
git checkout testnightversion
git pull upstream night-version // works fine.
Related videos on Youtube
Malloc
Updated on February 11, 2022Comments
-
Malloc over 2 years
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?
-
Oleh Liskovych almost 7 yearsHow to find this .swp file?
-
RUKAclMortality over 6 yearsHow to find "the session" - what does it mean?
-
Tengerye about 6 yearsBy finishing it, what exactly option should I choose? Edit or Recover it?@trojanfoe
-
Leticia Esperon almost 6 yearsCan you elaborate more on how to finish the session or delete the file?
-
Robert Sinclair almost 6 yearssee my answer below for details on how to remove the .swp file
-
zero_cool over 5 yearsthank you - to whomever is crafting this in the bash program - there should be a comment along the lines of: "If you'd like to keep your changes, and delete the old changes - press D"
-
ClownBaby over 4 yearsTo add to this: The folder may be hidden so you first have to run: cd .git
-
vikas kumar over 4 yearsor just hit git clean -f
-
RayLoveless over 4 years@OlehLiskovych It's in the git message or just search your git directory for a .swp file.
-
KRISHNA KANT SINGH over 4 yearsrm -rf ~.MERGE_MSG.swp should work @LeticiaEsperon @ OlehLiskovych
-
SteveExdia over 2 yearsHow do I "Find the session"? If I'm running
:sw
in my current editing session, that's not the same as the previous editing session, which in my case is probably from a server-closed ssh session that I no longer have access to. -
ScottyBlades about 2 yearsI don't have an ongoing commit nor merge, I can't figure out how to remove this effing file.
-
ScottyBlades about 2 yearsrm: .MERGE_MSG.swp: No such file or directory
-
Abdur Rahman about 2 yearsTo run the command, if your .MERGE_MSG.swp is hidden then must need go to the directory where the file is exist. @ScottyBlades