Push to GitHub mistakenly done by another GitHub account

Viewed 116

I had a local repository named a which had been already associated with a remote repository named A of GitHub account A-github, and I also had a local repository named b which had not been associated with any remote repository yet.

I created a new remote repository named B of GitHub account B-github, and I tried to do the first push to B from local repository b.

What happened

  • The push succeeded and I saw the page of B reflected the commits of b.
  • However, the name of the user who had done the first push displayed on the page of B was not the name of b, but the name of the other GitHub account A-github.(The icon image was also the same as set in A-github page)
  • And when I clicked the name of the user who first pushed ( A-github), I went to the page of A-github account.
  • What is weird is that this happening is not recorded on Contribution activity on the Overview page of A-github.

My guess

I'm guessing this was the problem of git config of the local repository b. I tried git config -l and found that user.name and user.email were doubled like this:

...
...
user.name = the user name I use for repository `a` and `A`
user.email = the user email I use for repository `a` and `A`
...
...
user.name = the user name I use for repository `b` and `B`
user.email = the user email I use for repository `b` and `B`
...
...
...

I want to let git use a right user (b) to do push to B and if I can, I want to cancel the push done by A-github

What should I do?

Progress

I've installed git filter-repo via package manager and tried the method shown here,

using git filter-repo --mailmap my-mailmap with the text file formatted as

Correct Name <correct@email.com> <old@email.com>

Then, I pressed enter. However, the result is the shell just returned

Python

and it seems nothing happened. I think I need some more trials.

Am I doing right?

I'm a bit afraid that I'm using git filter-repo correctly.

My comprehension is that I firstly need to create a text file named as formatted below:

Correct Name <correct@email.com> <old@email.com>

where Correct Name and <correct@email.com> is the name and email with which I want to replace the ones of present author and committer already written in the commit log, <old@email.com> is the present email written in log.

I'm entering email with putting <> on both ends.

Is this ok?

Progress 2

I found that it seemed I needed Python installed in advance on my PC to use git-filter-repo command, so I installed Python via Scoop a while ago. I tried again implementing the command above, and this time the shell returned:

Cannot read my-mailmap

Another difficulty came.

Now that the discussion is going off this topic,I posted a new question and I would close this question. Thanks for the advice.

1 Answers

First, do a git config -l --show-scope --show-origin in your repository: that way, you will be sure to see what is a local config, which overrides a global config.

Second, you can use git filter-repo to change the user.name/email of your commits in repoB: yo will then need to git push --force it (which is not a big issue if you are alone working on that new repository).

Related