skip to Main Content

I am currently working with a team of several people on single repository. All is fine when we are developing on our branches and local machines. However we also have a remote machine which we use it to run the project and sometime due deadlines we just ssh into the remote machine and develop inside the repository directly.

Since every time the git credentials needed to be changed it causes a problem and if we define a common credential like server/[email protected] it cause a problem on who did the commits

Is there a way to transfer the git credentials inside remote machine repository?

2

Answers


  1. Chosen as BEST ANSWER

    After searching I found a VS Code extension which enable fast switching between git identities


  2. TL;DR

    Each user has their own global ~/.gitconfig on the remote, where they can save settings specific to themselves.

    Details

    While I don’t know if any way for the local and global git config files to be "forwarded" to the remote (i.e., for ~/.gitconfig and .git/config on your own machine to be effective on the remote), each user can have their own ~/.gitconfig on the remote server, which will be effective for them there.

    Since the key thing you want is for commits made on the remote to reflect the user who made the commit, each user should run these commands on the remote:

    git config --global user.name "My name"
    git config --global user.email "[email protected]"
    

    or maybe even copy their whole ~/.gitconfig from their own machine to the remote.

    Then when any user does a commit on the remote, their name and e-mail will be used to create the commit.

    In order to avoid conflicts between users, avoid setting the local sandbox config for these settings, because the same local sandbox config will be shared among all the users.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search