我有一个关于 git 的问题。最近我犯了一个错误,并使用 git add -f path/to/folder 在我的 repo 中添加了一个目录。现在我非常努力地忽略这个文件夹,但没有任何效果。到目前为止,我做到了:
git update-index --assume-unchanged path/to/folder
上面的命令完成了这项工作,但是一旦我使用 chmod -R 777 授予该文件夹的权限,更改就会再次出现在 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")
编辑:也许我之前有点不清楚。所以基本上对于我的项目,我希望添加它们文件夹的当前内容tmp/
,但 git 不再跟踪更改。所以我这样做了:
$ git update-index --assume-unchanged app/tmp/
Ignoring path app/tmp/
但是现在,为了让我的应用程序再次运行,我需要为文件夹中的文件提供写权限,所以我做了:
sudo chmod -R 777 app/tmp/
但是一旦我这样做了,我就会在Changes not staged for commit:下看到你可以在上面看到的日志。我不希望跟踪这些更改,只是忽略。
仅供参考,这是我的 gitignore 中的内容:
/app/tmp/*