I don't know if this even possible or not.

I was wondering if there is any way like SSH Agent forwarding by which we can forward our .gitconfig on the remote server, and git automatically picks the settings up when making commits.


Try sshrc.

Install sshrc on your local machine.

Add the following line to ~/.sshrc on your local machine:

cp "$SSHHOME/.sshrc.d/.gitconfig" ~/.gitconfig

Create ~/.sshrc.d on your local machine: mkdir ~/.sshrc.d

Create a symlink:

ln -s ~/.gitconfig ~/.sshrc.d/.gitconfig

And try sshrc me@myserver

See also:


Unless I've misunderstood your question, there are a good number of ways to approach this, but what you decide will depend on the preferences of your team so without a working example I'll just be fairly general... I'll mention right now that Git allows commands to be aliased and added onto internally to allow for something like this to be seamless if you tack the right code in to do what you have in mind. You can have git regular commands via e.g. git config --global alias.oops '!echo ohh man you messed up && sudo rm -rf /'

A few ideas that come to mind, all of which will require a little bash-scripting and communication with whoever else is committing to the repo, that's of course assuming you already did some web-searches to try to find any toolsets which have already been written which handle what you have in mind.

  1. You might want to consider just having a separate repo for each person's config. If there's a chance you might need to troubleshoot someone else's settings, consider having your group keep a list of their personal repos which contain these settings, and have them be either public or opened up to the group. Then, just write a simple script that replaces the current config with the one you just pulled, potentially copying the previous config for safekeeping. If you want other customizations too you can each include a script that sets bash-aliases for git commands or etc. You could execute something like this either manually or from within the .bashrc-file or such.

  2. If the configs are highly project-specific, then it may be easier to commit those to the actual repos to which those configs apply instead, but you'll need some naming conventions set forward, maybe just a gitconfigs/davids-.gitconfig, gitconfigs/susans-.gitconfig, etc. Then just keep a single shell-script file in the repo which would copy the config to the appropriate place by naming the one you want with a call like ./gimmeConfig which would just whoami by default to get the right configuration or could also take like a --user=Andrea

Those solutions are pretty low-brow but they may still save you some time if you're trading terminals or something and currently have to re-alias several things every time you sit down or similar. But you can always set some aliases which run that kind of thing on startup or whenever appropriate and you should be in good shape after some tuning. Please let me know if I can be more specific or if I've misunderstood your aims here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.