Git remove tracked files-How to stop tracking and ignore changes to a file in Git?

312    Asked by Aashishchaursiya in Devops , Asked on Nov 30, -0001

 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 creating a patch), but clearly, they are needed in the project.

I have added *.csproj to my LOCAL .gitignore, but the files are already in the repo.

When I type git status, it shows my changes to csproj which I am not interested in keeping track of or submitting for patches.

How do I remove the "tracking of" these files from my personal repo (but keep them in the source so I can use them) so that I don't see the changes when I do a status (or create a patch)?

Is there a correct/canonical way to handle this situation?

Answered by Abdul Rehman

There are 3 options to resolve I think for the question 3 options that are required such as:

Option1:

To Stop tracking file git, but delete for everyone once they try to pull

git rm --cached or git rm -r --cached

Option2:

This is for optimization, like a folder with a large number of files, The assume-unchanged index will be reset and file(s) overwritten if there are upstream changes to the file/folder (when you pull).

git update-index --assume-unchanged

Option 3:

In this option you will tell git that you want your independent version of the file and you don’t want to overwrite production/config files.

git update-index --skip-worktree

Note: It will not propagate with git, and each user has to run it independently.



Your Answer

Interviews

Parent Categories