On 9/10/16, Jakub Narębski <jnareb@xxxxxxxxx> wrote: > You would need post-checkout hook together with clean / smudge filters > (though you could get by without smudge filter, at least in theory...). > The `post-checkout` hook could run e.g. "git checkout -- '*.conf'" > to force use of smudge filter, after checking that it was a change > of branch ("git checkout <commit-ish>"). See githooks(5) for details > (last, third parameter passed to hook script is 1, rather than 0). Neat idea. I could still have an advantage of filter as git status wouldn't show that files are changed and there would be no merge conflicts and additionally filters would run after every checkout even if files stayed the same. But are sure that `git checkout -- <FILE>' actually forces checkout and runs smudge filter? It doesn't work for me neither with 2.9.0 nor 2.10.0.85.gcda1bbd. For a minimal example, let's say that I have this in .gitattributes: a filter=test-filter And this in .git/config: smudge = touch /tmp/SMUDGE_RUN && cat And also have a tracked file named `a' in the repository. Now this should create /tmp/SMUDGE_RUN: git checkout -- a but it doesn't. This also doesn't work: git checkout -f -- a But this does: git checkout HEAD^ && git co - > Unfortunately I don't see a way to query .gitattributes files to > find out all patterns that match specific attribute; you would need > to duplicate configuration: > > .gitattributes: > *.conf filter=transform > > .git/config > [filter "transform"] > clean = replace-with-placeholder %f > smudge = expand-with-branchname %f > > .git/hooks/post-checkout > #!/bin/sh > > test "$3" -eq "1" && git checkout -- '*.conf' It's a secondary issue, but - in my repository I only have one .conf file on every branch with real definitions of machine-specific variables and a number of various config files for various programs such as bash/.bashrc or screen/.screenrc so in my case it would be: .gitattributes: bash/.basrc filter=transform git/.gitconfig filter=transform (...) .git/config [filter "transform"] clean = replace-with-placeholder %f smudge = expand-with-branchname %f .git/hooks/post-checkout #!/bin/sh test "$3" -eq "1" && ( git checkout -- bash/.bashrc && git checkout -- git/.gitconfig (...) ) Of course a list of files in .git/hooks/post-checkout could be generated at runtime from first column of .gitattributes. -- <wempwer@xxxxxxxxx>