I work with a git repository via TRAMP (and magit, but that doesn't seem to be important). Repository's owner is user x, and x's umask is 022. All operations on the repository are done via /sudo:x@.../ My umask, however, is 077. I can't make Emacs use a umask that would be appropriate to the context. It seems to always use a global umask. I searched the mailing list, found this thread https://lists.gnu.org/archive/html/help-gnu-emacs/2016-06/msg00214.html It resolves with the recommendation to use tramp-handle-write-region-hook. With git repository, this won't help as operations are performed by git. E.g. a rebase messes up everything. There is another suggestion there that recommends to alter x's .profile and set umask depending on a value passed via tramp-remote-process-environment. I just altered x's .profile to set umask *unconditionally*, and it has no effect. So far, the way Tramp treats umask makes absolutely no sense to me. What are my options?