Question

I am working on a project where another person have joined recently. I am using GitHub as our SCM to do all kind of PUSH, PULL, COMMIT etc activities. Now I want to have another person to work with me on the project, but I can't have a separate account for the other person to do all the GitHub operations. So what I need is, if the other person can use my account to do all the GitHub operations then that will work.

Eventually when that person does any kind of GitHub operation it show my name as author name To achieve that I have created the SSH key on the other persons machine, and registered that with my GIT account. But what else needs to be done.

I know it will be best to have a separate GitHub account for the other person, having separate SSH and do separate COMMITS etc. But for some reason I can't afford that now.

Explanation with an example: 2 persons- Marcus and Ryan working on a project. Marco has a GitHub account using which he does all his GitHub operations. Now Ryan also needs to use Marcus account to all GitHub operations, and it will appear Marcus as author.

How can I achieve it.

Was it helpful?

Solution

This is all you need:

  • Add ssh keys of both users
  • Make both users use the same user.name and user.email:

    git config --global user.name "Your Name"
    git config --global user.email you@your.domain.com
    

Well, for the user who has to set not his real name and email, a global setting will be too inconvenient. It will be better to make the setting only in the repository in question. You can do that by running these commands inside the working tree of the repo without the --global flag:

git config user.name "Your Name"
git config user.email you@your.domain.com

With this setup, GitHub won't be able to tell the difference between the two different users. It will appear as if it's the same person using multiple ssh keys.

If you think you need this to work with private repositories, then you don't need this. The fork of a private repository will be private too.

OTHER TIPS

Now Ryan also needs to use Marcus account to all GitHub operations, and it will appear Marcus as author.

True, as explained in "Why are my commits linked to the wrong user?"

GitHub uses the email saved in a commit's header to link the commit to a GitHub user

But the author remains Ryan, and a git blame would still work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top