How to ignore existing file in Git?

前端 未结 7 513
南笙
南笙 2021-02-05 19:31

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.

Is this possible

7条回答
  •  遇见更好的自我
    2021-02-05 20:11

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

    So git update-index --skip-worktree file.txt

    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.

提交回复
热议问题