gitgit-assume-unchanged

How can I reset my commits while keeping my assume-unchanged files in git?


I have quite many files that I set as

git update-index --assume-unchanged <file>

In some cases my branch is messed up and diverged with origin/master. Let's say

and have 4 and 8 different commits each, respectively.

So I want to revert all my commits and keep update to origin/master while keeps my assume-unchanged files not being flushed. How can I do this?


Solution

  • Instead of using --assume-unchanged, you can try --skip-worktree with git update-index.

    A file with the flag git update-index --skip-worktree should resist a git reset (which would unstage from the index any added changes)

    You can see a full analysis of the differences between --assume-unchanged and --skip-worktree here.

    It looks like --skip-worktree is trying very hard to preserve your local data. But it doesn’t prevent you to get upstream changes if it is safe. Plus git doesn’t reset the flag on pull.
    But ignoring the 'reset --hard' command could become a nasty surprise for a developer.