How to stop tracking and ignore changes to a file in Git?

前端 未结 20 1701
梦谈多话
梦谈多话 2020-11-21 07:17

I have cloned a project that includes some .csproj files. I don\'t need/like my local csproj files being tracked by Git (or being brought up when c

20条回答
  •  离开以前
    2020-11-21 07:54

    Just calling git rm --cached on each of the files you want to remove from revision control should be fine. As long as your local ignore patterns are correct you won't see these files included in the output of git status.

    Note that this solution removes the files from the repository, so all developers would need to maintain their own local (non-revision controlled) copies of the file

    To prevent git from detecting changes in these files you should also use this command:

    git update-index --assume-unchanged [path]
    

    What you probably want to do: (from below @Ryan Taylor answer)

    1. This is to tell git you want your own independent version of the file or folder. For instance, you don't want to overwrite (or delete) production/staging config files.

    git update-index --skip-worktree

    The full answer is here in this URL: http://source.kohlerville.com/2009/02/untrack-files-in-git/

提交回复
热议问题