Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“如何解决git合并错误”;交换文件.MERGE“u MSG.swp已存在”;_Git_Github_Github For Mac - Fatal编程技术网

“如何解决git合并错误”;交换文件.MERGE“u MSG.swp已存在”;

“如何解决git合并错误”;交换文件.MERGE“u MSG.swp已存在”;,git,github,github-for-mac,Git,Github,Github For Mac,当我拉: E325: ATTENTION Found a swap file by the name "~/Documents/Sites/recipegenerator/.git/.MERGE_MSG.swp" owned by: username dated: Wed Dec 14 12:28:45 2016 file name: ~username/Documents/Sites/recipegenerator/.git/MERGE_MSG

当我拉:

E325: ATTENTION
Found a swap file by the name "~/Documents/Sites/recipegenerator/.git/.MERGE_MSG.swp"
          owned by: username   dated: Wed Dec 14 12:28:45 2016
         file name: ~username/Documents/Sites/recipegenerator/.git/MERGE_MSG
          modified: YES
         user name: username   host name: Users-MacBook-Pro.local
        process ID: 33747
While opening file "/Users/larsvanurk/Documents/Sites/recipegenerator/.git/MERGE_MSG"
             dated: Thu Dec 22 14:06:17 2016
      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 /Users/username/Documents/Sites/recipegenerator/.git/MERGE_MSG"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/Users/username/Documents/Sites/recipegenerator/.git/.MERGE_MSG.swp"
    to avoid this message.

Swap file "~/Documents/Sites/recipegenerator/.git/.MERGE_MSG.swp" already exists!
当我推:

To  https://github.com/nickname/recipegenerator.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/nickname/recipegenerator.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

请帮助:C Idk做什么。我不能推也不能拉。我几乎用尽了我所能想到的一切。我还尝试了:git merge--abort。问题是,当我这样做时,我似乎找不到我应该解决的冲突。

这是一条来自VIM的消息,显然您正在使用它作为git中的文本编辑器。您是否尝试阅读并遵循这两(1)(2)点?其中一个可能是正确的,它会让你解决这个问题

首先,检查
MERGE\u MSG
文件(不是MERGE\u MSG.swp),看看它是否存在以及里面有什么。最有可能是垃圾或可以安全删除的临时文件。从名称判断,它可能是用作合并提交消息的临时文本编辑区域的文件名

然后,由于您使用VIM,当VIM启动时,它会尝试创建一个交换文件以满足其内部需要。错误消息说它是
~/Documents/Sites/recipegenerator/.git/.MERGE\u MSG.swp
。通常,您可以简单地删除此类交换文件,尤其是当它们是旧文件或意外文件时。但是,如果最近某个合并提交消息编辑会话崩溃,并且如果您有大量不想丢失的创造性文本,则不要删除它,而是恢复该交换,如错误消息(2)中所述

但是,由于您不知道发生了什么,也没有说过会丢失一些您编写的文本,而且可能只是自动生成的合并消息,我想您可以:

git merge --abort
rm ~/Documents/Sites/recipegenerator/.git/.MERGE_MSG.swp
再试试你在做什么


此外,在错误消息中检查(1)中提到的提示也很好。使用
ps
或任何其他工具检查当前正在编辑合并消息的任何打开的VIM会话。如果你发现了任何交换,那么,好吧,找到它们并完成编辑,或者让它们退出(escape,:q!,enter)(vim将在退出时清理交换),或者终止它们(杀死它们,但是你需要手动删除交换文件)。

我的终端也有同样的问题,我退出了终端,它对我有效

出现了相同的问题,并修复了退出终端并再次提交的问题。

您需要通过

git merge --abort
然后您需要删除合并消息文件

转到项目目录并通过以下命令删除文件

rm .git/.MERGE_MSG.swp
您还可以使用以下单个命令来完成此操作

git merge --abort && rm .git/.MERGE_MSG.swp

在我的例子中,关闭VI编辑器时出现问题

  • 重新启动终端不起作用

  • 重新启动mac解决了这个问题

这里可能有相同的副本我关闭了终端并重新启动了它,它被解决了这与我4年前的回答有什么不同?不过,它肯定比我的更简洁:)“重启我的mac解决了这个问题。”-它不应该有任何区别。如果有,那么显然您已经运行了另一个VIM进程。当您重新启动mac时,所有应用程序都被关闭,rogue VIM会话清除了它的垃圾。下一次,试着运行PS(或者mac上的任何东西),看看是否有任何VIM进程是你不期望的。@Quetzalcatl,这对我来说是一个改变。当我重定基址时,我的电脑死机了,所以我强迫它关机。因此,当我重新打开计算机时,系统会提示我是否要继续会话。我选择了“是”,然后当我试图继续我的重基时,我得到了OP在问题中提到的错误。中止再基地也无济于事。但是重新启动我的mac电脑做到了。我打赌如果回答提示“否”以重新启动新状态,则不会发生此错误。