Допустим, у нас есть следующий репозитарий:
$ git ls-files file_for_hold file_for_sync $
Изменяем оба файла:
$ echo 'test' | tee file_for_hold > file_for_sync $ head * ==> file_for_hold <== test ==> file_for_sync <== test $ git status # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: file_for_hold # modified: file_for_sync # no changes added to commit (use "git add" and/or "git commit -a") $
git хочет закоммитить оба файла. Т.к. file_for_hold у нас уже в репозитории, то его добавление в git-ignores тем или иным способом не подходит.
Необходимо обновить данные индекса локального репозитория, чтобы изменения file_for_hold не учитывались:
$ git update-index --assume-unchanged file_for_hold $ git status # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: file_for_sync # no changes added to commit (use "git add" and/or "git commit -a") $
Что и требовалось получить.
Дискуссия