我将本地 GIT 存储库复制到其他位置,但无法提交

发布于 2025-01-05 02:03:01 字数 837 浏览 2 评论 0原文

我将本地 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傾旎 2025-01-12 02:03:01

当 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

倾其所爱 2025-01-12 02:03:01

为了补充上面海报的解释,可能值得一提的是,您可以配置 vim 将其所有 .swp 文件保存到特定目录中。

以后,如果您想避免此类问题,只需在您的 ~/.vim/ 目录中创建一个目录 swap_files ,并将此行添加到您的 中即可。 vimrc.

set directory^=$HOME/.vim/swap_files/

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.

set directory^=$HOME/.vim/swap_files/
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文