Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

emacs

tramp

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?

like image 250
Tim Landscheidt Avatar asked Jun 03 '13 20:06

Tim Landscheidt


1 Answers

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.

like image 169
Klas Mellbourn Avatar answered Oct 22 '22 20:10

Klas Mellbourn