somia
somia

Reputation: 193

Push to GitHub mistakenly done by another GitHub account

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

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 <[email protected]> <[email protected]>

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 <[email protected]> <[email protected]>

where Correct Name and <[email protected]> is the name and email with which I want to replace the ones of present author and committer already written in the commit log, <[email protected]> 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.

Upvotes: 2

Views: 626

Answers (1)

VonC
VonC

Reputation: 1323263

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).

Upvotes: 1

Related Questions