如何忽略Git中的现有文件? [英] How to ignore existing file in Git?

查看:94
本文介绍了如何忽略Git中的现有文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在本地和Git中使用不同的内容处理 file.txt 。我希望Git不要告诉我该文件已经发生变化。

I need to work on file.txt locally and in Git, with different content. I want Git not to tell me that there have been changes to that file.

这可能吗?

推荐答案

实际上,您需要 - skip-worktree ,而不是 - 承担 - 不变这是一个很好的解释为什么

Actually, you want --skip-worktree, not --assume-unchanged. Here's a good explanation why.

因此 git update-index --skip-worktree file.txt

TLDR; - 假设 - 不变用于性能,对于不会改变的文件(如SDK); - skip-worktree 用于远程存在的文件,但您希望进行本地(未跟踪)更改。

TLDR; --assume-unchanged is for performance, for files that won't change (like SDKs); --skip-worktree is for files that exist on remote but that you want to make local (untracked) changes to.

这篇关于如何忽略Git中的现有文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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