3

There is a certain file that I want to share in its current state, but I don't want further changes to be committed. So I did "assume-unchanged" to that file. Now, git ignores changes to this file in my repository. But what about other users of the repository - will they have to do "assume-unchanged" for this file in their own repository?

Is there a way to automatically make the "assume-unchanged" directive valid for other users too, as it is done with the "gitignore" information?

Erel Segal-Halevi
  • 33,955
  • 36
  • 114
  • 183
  • Think about it: when you mark a file as assume-unchanged, and then run `git commit`, does it let you commit, or does it tell you there is nothing to commit? (It's the latter.) If you cannot commit, how can you get the assume-unchanged information to others? –  Oct 31 '14 at 08:32
  • It could be commited just like the ignore information - through a file such as ".gitignore". – Erel Segal-Halevi Oct 31 '14 at 08:36
  • Yes, it could be, but it isn't, and it's easily verified that it isn't. Don't get me wrong, it's a perfectly reasonable question to ask yourself, but it's a question to which you should be able to find the answer rather quickly just by trying. –  Oct 31 '14 at 08:46
  • Yes, I saw that nothing is committed, but I thought that maybe I was doing something wrong... I can never be sure. – Erel Segal-Halevi Oct 31 '14 at 08:53
  • Now that could be a far more interesting question. :) If you *want* to make sure other users of the repository get the same `assume-unchanged` settings, how would you do it? (Personally, I'd try to rework the project so that there's no need for it, and if that's not possible, I'd include a script in the project to set it up that other users can run if they so choose.) –  Oct 31 '14 at 09:00
  • I have edited my answer with an alternative. – VonC Oct 31 '14 at 10:09

1 Answers1

3

No, git update-index --assume-unchanged only updates the index of your local repo.

Not the index of any other remote repo, and this is not pushed.
that would be the same for git update-index --skip-worktree

One approach which can be pushed around is using a content filter driver, in order to generate the actual file from a versioned template.
See for instance "Automatically ignore selected code changes when pushing to a git-hub repository"

https://i.stack.imgur.com/77Oy5.png

(image from "Customizing Git Attributes" from the Git Book)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250