I have a NetBeans file "nbproject/project.properties" that always shows up in the "Changes not staged for commit" section (when I do git status). How could I move this to the Untracked files section (without adding it to .gitignore) ? I tried this command git rm --cached
but what happened is the file shows as untracked in my local repo and got removed in the remote one but what I want is to keep it in remote and untrack only in local repo.
You can of course use git rm --cached , which removes it only from the index, leaving it untouched in the work-tree.
Tell Git to untrack file Use git rm to Git untrack file. Both of the commands above git untrack file without deleting. This is because of the cached option. Removing the cached option will delete it from your disk.
The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area.
“git untrack file” Code Answer's git rm -r --cached . – Remove all tracked files, including wanted and unwanted. Your code will be safe as long as you have saved locally. git add .
You could update your index:
cd /root/folder/of/your/repo git update-index --assume-unchanged nbproject/project.properties
and make sure it never shows as "updated" in your current repo.
That means it won't ever be pushed, but it is still present in the index.
(and it can be modified at will in your local working tree).
git update-index --no-assume-unchanged <file>
git ls-files -v | grep '^h '
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With