How do I protect git-assume-unchanged files from being overwritten by remote?

460 Views Asked by At

The following behaviour is wondering and annoying me:

  1. I have a file in my local repository.
  2. I push into the remote repository. (Note: I need the file in my repository!)
  3. Now I want to perform local edits, that shall not be pushed remotely (e.g. a configuration customizing for my local machine only).
  4. By using git update-index --assume-unchanged I tell git not to track changes to this file.
  5. But when I do a git checkout -f, my local file is overwritten again.

What would be a better way to keep my local changes but not push them remotely? Or: if there is something wrong in my procedure, what should I change?

1

There are 1 best solutions below

5
On

use .gitignore to intentionally specify files to ignore.

1 - add file in local (with no specific configuration)
2 - push to remote
3 - add file to .gitignore
4 - customize your local config
5 - do stuff
6 - push to remote
-> file will be ignored and stay as is on remote.