4

Is there a variation on git update-index --skip-worktree that will make the file be treated as unchanged but only until the next time the file is modified?

In other words, I'm looking for a self-cancelling --skip-worktree equivalent.

My motivation is that I've made some changes that I don't want ever to commit. But if I ever make any further changes to the same file I want it immediately to reappear in the list of modified files so that I am prompted to consider if the new changes should be committed. If I use git update-index --skip-worktree then I am likely to forget.

(There are lots of similar questions and answers but none of them describe a 'self-cancelling' method, e.g. https://stackoverflow.com/a/3320183/127670.)

Ian Goldby
  • 5,609
  • 1
  • 45
  • 81
  • *"I've made some changes to a file that I don't want ever to commit."* -- either the file should be in `.gitignore` (and never added to the repo) or the changes should stay in a different file (that is ignored by Git). – axiac May 03 '18 at 10:56
  • "until the next time the file is modified" - you mean, modified by local user? – max630 May 03 '18 at 11:16
  • because `--skip-worktree`, I believe, should be removed if the file has changed remotely and you checkout the new version. – max630 May 03 '18 at 11:18
  • I'd look at [clean filter](https://git-scm.com/docs/gitattributes#_code_filter_code) – max630 May 03 '18 at 11:22
  • @max630 I mean primarily until modified by the user. It's to stop me forgetting to commit changes that *should* be pushed in the file. Obviously if the file is modified remotely it needs to do something sane, like pull in the remote changes and (try to) merge with the local version. Whether that triggers the 'self-cancelling' doesn't really matter. – Ian Goldby May 03 '18 at 11:45
  • Did you find a solution? – Vincent Feb 23 '21 at 17:22
  • 1
    @Vincent No, I don't think it's possible. – Ian Goldby Feb 24 '21 at 08:12

0 Answers0