How to set different author/committer for Git in TRAMP environment?
Asked Answered
C

1

6

I edit files under Git control with Emacs 23.3.1/TRAMP/VC sudoed over an ssh connection (/sudo:sudouser@host:file with tramp-default-proxies-alist set accordingly). sudouser is a shared account, so I don't want to set user.email/user.name globally, but instead use GIT_AUTHOR_NAME/GIT_AUTHOR_EMAIL/GIT_COMMITTER_NAME/GIT_COMMITTER_EMAIL to set it just for my connection.

I did not find a way to set an environment/change the command in vc-git itself. Adding the environment variables to tramp-remote-process-environment:

(add-to-list 'tramp-remote-process-environment "[email protected]")
(add-to-list 'tramp-remote-process-environment "GIT_AUTHOR_NAME='Tim Landscheidt'")
(add-to-list 'tramp-remote-process-environment "[email protected]")
(add-to-list 'tramp-remote-process-environment "GIT_COMMITTER_EMAIL='Tim Landscheidt'")

works, but I fear it might bite me in the future when I want to work on a host where I need another identity.

Is there a way to set a different author/committer limited to one TRAMP connection?

Czarevna answered 3/6, 2013 at 20:42 Comment(0)
W
2

I know nothing of TRAMP, but I can point out that you can set user.email and user.name individually for a particular repository by setting them in .git/config or by doing the commands:

git config --local user.name "Tim Landscheidt"
git config --local user.email "[email protected]"

So that way you can have different settings for author/committer for each repository.

Whaleback answered 3/6, 2013 at 21:10 Comment(1)
Whether the identity is set in ~/.gitconfig or .git/config doesn't matter; the problem is that it is a shared account, and I don't want others (accidentally) posing as myself.Czarevna

© 2022 - 2024 — McMap. All rights reserved.