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

前端 未结 20 1703
梦谈多话
梦谈多话 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 08:02

    one line answer git update-index --assume-unchanged [path]

    Use this whenever you have a file that is in central repo and also local repo.you need to make changes in that file but must not be staged/committed to the central repo. This file should not be added in .gitignore. because new changes in the file if introduced by system administrators, senior developers needs to be distributed among all local repos.

    Best Example: config file for DB connections. In a central repo, you will have all the username,password, host,port with values of a production DB server. But in local dev, you should use only a local or any other development DB server(that your team has setup). In this case you wanna make changes in config file but should not be committed to central repo.

    Best

提交回复
热议问题