gpt4 book ai didi

git - 如何解决git merge 错误 "Swap file .MERGE_MSG.swp already exists"

转载 作者:IT王子 更新时间:2023-10-29 01:15:17 50 4
gpt4 key购买 nike

当我 pull 时:

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 做什么。我不能推也不能 pull 。我几乎尝试了所有我能想到的方法。我也试过:git merge --abort。问题是当我这样做时,我似乎找不到我应该解决的冲突。

最佳答案

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

首先,检查 MERGE_MSG 文件(不是 MERGE_MSG.swp),看看它是否存在以及里面有什么。它很可能是垃圾或可以安全删除的临时文件。从名字看,应该是作为 merge 提交信息的临时文本编辑区的文件名。

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

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

git merge --abort
rm ~/Documents/Sites/recipegenerator/.git/.MERGE_MSG.swp

然后再次尝试您正在做的事情。

另外,最好检查错误信息中(1)中提到的提示。使用 ps 或任何其他方式检查当前可能正在编辑该 MERGE_MSG 的任何打开的 VIM session 。如果你发现任何东西,那么,好吧,找到它们并完成编辑,或者让它们退出(转义,:q!,输入)(vim 将在退出时清理交换),或者终止它们(杀死它们,但是你需要手动删除交换文件)。

关于git - 如何解决git merge 错误 "Swap file .MERGE_MSG.swp already exists",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41284031/

50 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com