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

查看:26
本文介绍了如何忽略 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,而不是 --assume-unchanged.这是一个很好的解释.

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

所以 git update-index --skip-worktree file.txt

TLDR;--assume-unchanged 用于性能,用于不会更改的文件(如 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天全站免登陆