git 通过名称找到一个交换文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13361729/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Found a swap file by the name
提问by Malloc
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?
如何处理?
回答by trojanfoe
Looks like you have an open git commit
or git merge
going on, and an editor is still open editing the commit message.
看起来您有一个打开git commit
或git merge
正在进行,并且编辑器仍在打开编辑提交消息。
Two choices:
两种选择:
- Find the session and finish it (preferable).
- Delete the
.swp
file (if you're sure the other git session has gone away).
- 找到会话并完成它(最好)。
- 删除
.swp
文件(如果您确定另一个 git 会话已经消失)。
Clarification from comments:
从评论中澄清:
- The sessionis 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
).
- 该会议是编辑会话。
- 你可以看到
.swp
正在使用的输入命令:sw
编辑会话中,但通常它是在同一目录下,你正在使用的文件,隐藏文件,具有.swp
文件后缀(即~/myfile.txt
是~/.myfile.txt.swp
)。
回答by Robert Sinclair
Accepted answer fails to mention how to delete the .swp file.
接受的答案没有提到如何删除 .swp 文件。
Hit "D" when the prompt comes up and it will remove it.
出现提示时点击“D”,它将删除它。
In my case, after I hit D it left the latest saved version intact and deleted the .swpwhich got created because I exited VIM incorrectly
就我而言,在我点击 D 后,它保持最新保存的版本完好无损,并删除了创建的.swp,因为我错误地退出了 VIM
回答by Abdur Rahman
.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.
.MERGE_MSG.swp 在你的 git 中打开,你只需要删除这个 .swp 文件。就我而言,我使用了以下命令,效果很好。
rm .MERGE_MSG.swp
回答by jitendrapurohit
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
例如 - 这会创建一个新night-version
的上游分支匹配
git checkout upstream/night-version -b testnightversion
This creates a branch testmaster
in local which matches the master
branch of upstream.
这会testmaster
在本地创建一个与master
上游分支匹配的分支。
git checkout upstream/master -b testmaster
Now if I try to pull the changes of night-version
into testmaster
branch leads to this error.
现在,如果我尝试将更改拉night-version
入testmaster
分支会导致此错误。
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.