“如何解决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解决了这个问题