git创建以〜结尾的文件? [英] git creates files ending in ~?

查看:204
本文介绍了git创建以〜结尾的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚开始在我的Mac上使用git。我的存储库中有一个名为 README 的文件。当我改变它的时候,git会把另一个文件放在名为 README〜的目录中,其中包含以前的版本。

Just started using git on my mac. I have one file in my repository called README. When I change it, git puts another file in the directory called README~ containing the previous version.


  1. 是否git执行此操作?

  2. 为什么git会执行此操作?

  3. 如何阻止git执行此操作? (不要只是将它添加到 .gitignore 中,但我想我可以做到这一点,但我宁愿明白为什么我要首先获取这些文件...)

  1. Is it git doing this?
  2. Why is git doing this?
  3. How can I stop git doing this? (don't just want to add it to .gitignore, but I guess I could do that but I'd rather understand why I'm getting these files in the first place..)

(在Google搜索上搜索〜时很难找到答案)

(It's hard to search for an answer on Google cos of trying to search on "~")

推荐答案

在编辑的文件的备份副本上,编辑器(Emacs,Vim在某些模式/版本中)通常使用文件名上的波浪号后缀。曾经在Mac上,Vim似乎为我创建了备份;它不再是了,但我现在还不确定这是因为我在某处调整了一个设置,还是vim改变了它的行为。

The tilde suffix on file names is usually used by editors (Emacs, Vim in some modes/versions) on backup copies of files you edit. At one time on Mac, Vim seemed to create backups for me; it doesn't any more, but I'm not sure now whether that's because I tweaked a setting somewhere or whether vim changed its behaviour.

我还没有看到git add (或者在我主要工作的Mac上,或者任何其他地方)。

I have not seen git add tilde suffixes to file names (either on a Mac where I work mainly, or anywhere else).

要停止想要添加文件的git,添加一行只包含 *〜 .gitignore

To stop git wanting to add the files, add a line containing just *~ to .gitignore.

至少)与此相关的三项设置:

Vim has (at least) three settings related to this:

nobackup
  backupcopy=auto
  backupext=~

我的:设置所有'显示上面的值。你可能会显示'备份'而不是' nobackup '。

My ':set all' shows the values above. Yours probably shows 'backup' rather than 'nobackup'.

这篇关于git创建以〜结尾的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆