Having trouble “untracking” file (ignore further changes to tracked file)
I have an issue on git. Recently I made a mistake and added a directory to my repo by using git add -f path/to/folder. Now I’m trying really hard to ignore this folder but nothing works. So far I did :
git update-index --assume-unchanged path/to/folder
The command above did the job but once I give the right to this folder using chmod -R 777 the change appear again in git status :
# Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: app/tmp/cache/models/myapp_cake_model_default_contractsign_attachments # modified: app/tmp/cache/models/myapp_cake_model_default_contractsign_list # modified: app/tmp/cache/models/myapp_cake_model_default_contractsign_signatures # modified: app/tmp/cache/models/myapp_cake_model_default_contractsign_users # modified: app/tmp/cache/persistent/myapp_cake_core_cake_dev_eng # modified: app/tmp/cache/persistent/myapp_cake_core_cake_dev_fre # modified: app/tmp/cache/persistent/myapp_cake_core_cake_dev_spa # modified: app/tmp/cache/persistent/myapp_cake_core_cake_eng # modified: app/tmp/cache/persistent/myapp_cake_core_cake_fre # modified: app/tmp/cache/persistent/myapp_cake_core_cake_spa # modified: app/tmp/cache/persistent/myapp_cake_core_default_eng # modified: app/tmp/cache/persistent/myapp_cake_core_default_fre # modified: app/tmp/cache/persistent/myapp_cake_core_default_spa # modified: app/tmp/cache/persistent/myapp_cake_core_file_map # modified: app/tmp/cache/persistent/myapp_cake_core_method_cache # modified: app/tmp/logs/error.log # no changes added to commit (use "git add" and/or "git commit -a")
EDIT: Maybe I was a bit unclear before. So basically for my project, I want the current contents of them
tmp/ folder added, but changes no longer be tracked by git. So I did this:
$ git update-index --assume-unchanged app/tmp/ Ignoring path app/tmp/
But now, in order to make my application work again, I need to give write permission for files in folder, so I did:
sudo chmod -R 777 app/tmp/
But once I did that, I got the log you can see above under Changes not staged for commit:. I don’t want those changes tracked, just ignored.
Just for information, here is what I have in my gitignore :
One Solution collect form web for “Having trouble “untracking” file (ignore further changes to tracked file)”
You appear to have mixed together different things because you don’t know what they do.
Marking a file as “assume-unchanged” will ignore further changes to a tracked file — this is not what you say you want. (Note: The question was originally saying the OP wants to untrack the files)
git rm --cached only removes a file from the index (staging area), but does not tell Git anything about ignoring it from now on, so you were on the right track, but you didn’t go all the way.
After removing the file (it is now untracked again, but Git always tells you about untracked content), you have to additionally add an entry for it to one of your ignore files in Git; then it will not show it again in the status message.
To do this, append this entry to the file
.gitignore in your repo’s root (create that file if it doesn’t exist yet):
Of course, don’t use that literally but use the actual path instead. Note that the leading slash does not mean “file system root” but “repo’s root” in this case.
Edit: After you have provided more information, your problem is clearer. You do not actually want to untrack some files (i.e. remove them from version control), but only ignore further changes to them.
For this, “assume-unchanged” is indeed the right way of going at it, but assume-unchanged does not work recursively on directories. That means that you will have to set it explicitly on every file whose changes you want to overlook. You can do this in a single command:
git update-index --assume-unchanged -- file1 file2 file3 ...
If there were a great many files, this could be scripted, but since you only seem to have about 15 files, it would take longer to make the script (files are in different directories) than for you to just copy-paste the paths into a command.