我将本地 GIT 存储库复制到其他位置,但无法提交
我将本地 git 存储库复制到了站点文件夹,以便我可以在本地进行开发,然后将更改推送到 github。
当我尝试通过“git commit -a”提交时,我收到以下消息:
E325: ATTENTION
Found a swap file by the name “.git/.COMMIT_EDITMSG.swp”
owned by: usrname dated: Sat Feb 4 18:56:02 2012
file name: ~myUsername/oldRepoLocation/.git/COMMIT_EDITMSG
modified: YES
process ID: 15435
While opening file “.git/COMMIT_EDITMSG”
dated: Sun Feb 12 19:51:43 2012
NEWER than swap file!
(1) Another program may正在编辑同一个文件。 如果是这种情况,请小心不要最终出现两个问题 进行更改时同一文件的不同实例。 退出,或谨慎继续。
(2) 该文件的编辑会话崩溃。 如果是这种情况,请使用“:recover”或“vim -r .git/COMMIT_EDITMSG” 恢复更改(请参阅“:帮助恢复”)。 如果您已经这样做了,请删除交换文件“.git/.COMMIT_EDITMSG.swp” 以避免出现此消息。
交换文件“.git/.COMMIT_EDITMSG.swp”已经存在!
I copied my local git repo to my sites folder so that I can develop locally and then push changes to github.
When I try committing via "git commit -a" I get this message:
E325: ATTENTION
Found a swap file by the name ".git/.COMMIT_EDITMSG.swp"
owned by: usrname dated: Sat Feb 4 18:56:02 2012
file name: ~myUsername/oldRepoLocation/.git/COMMIT_EDITMSG
modified: YES
process ID: 15435
While opening file ".git/COMMIT_EDITMSG"
dated: Sun Feb 12 19:51:43 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/COMMIT_EDITMSG"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file ".git/.COMMIT_EDITMSG.swp"
to avoid this message.
Swap file ".git/.COMMIT_EDITMSG.swp" already exists!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当 Vim 运行时,它会为缓冲区中打开的每个文件创建一个 .swp 文件。这是为了崩溃恢复。
在这种情况下,您可能在打开 Vim 编辑提交消息时复制了存储库,从而将 .swp 文件保留在新副本中。删除错误的 swp 文件是安全的:
rm .git/.COMMIT_EDITMSG.swp
While Vim is running, it creates one .swp file per file open in a buffer. It's for crash recovery.
In this case, you probably copied the repo while Vim was opened to edit the commit message, thus keeping the .swp file around in the new copy. It's safe to delete the errant swp file:
rm .git/.COMMIT_EDITMSG.swp
为了补充上面海报的解释,可能值得一提的是,您可以配置 vim 将其所有
.swp
文件保存到特定目录中。以后,如果您想避免此类问题,只需在您的
~/.vim/
目录中创建一个目录swap_files
,并将此行添加到您的中即可。 vimrc
.To add to the above poster's explanation, it might be worth mentioning that you can configure vim to keep all its
.swp
files into a specific directory.In the future, if you want to avoid such problems, simply make a directory
swap_files
in your~/.vim/
directory, and add this line to your.vimrc
.