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
git rm --fileName
git ls-files
to make sure that the file is removed or untracked
git commit -m "UntrackChanges"
git push
As pointed out in other answers, the selected answer is wrong.
The answer to another question suggests that it may be skip-worktree that would be required.
git update-index --skip-worktree <file>
I am assuming that you are asking how to remove ALL the files in a specific folder or the bin folder, Rather than selecting each files separately.
You can use this command:
git rm -r -f /<floder-name>\*
Make sure that you are in the parent directory of the of that directory.
This command will, recursively "delete" all the files which are in the bin/ or build/ folders. By the word delete I mean that git will pretend that those files are "deleted" and those files will not be tracked. The git really marks those files to be in delete mode.
Do make sure that you have your .gitignore ready for upcoming commits.
Documentation : git rm
The accepted answer still did not work for me
I used
git rm -r --cached .
git add .
git commit -m "fixing .gitignore"
Found the answer from here
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)
- 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 <path-name>
The full answer is here in this URL: http://source.kohlerville.com/2009/02/untrack-files-in-git/
If you have the entire project locally but forgot to add you git ignore and are now tracking some unnecessary files use this command to remove everything
git rm --cached -r .
make sure you are at the root of the project.
Then you can do the usual
git add .
git commit -m 'removed all and added with git ignore'
git push origin master
Hope this helps out people who have to make changes to their .gitignore
or forgot it all together.