2

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.

somia
  • 193
  • 10
  • Yes `<>` is correct. You can see an example in https://git-scm.com/docs/git-shortlog#_mapping_authors (except, in your case, you need to include the new *and old* emails) – VonC Mar 15 '21 at 07:49
  • Thank you. I would like to some of the snippets shown that link. Now that the discussion is going off the first topic of this question, [I posted a new question](https://stackoverflow.com/questions/66634193/git-filter-repo-doesnt-read-my-mailmap-file) and I would close this question. Thanks for the advice. – somia Mar 15 '21 at 08:10

1 Answers1

1

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

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you. I tried git filter-repo as shown at the link, but it seems the command did not run properly. (Please see my new edit of this question above.) – somia Mar 14 '21 at 16:15
  • @somia Can you try the same command on a fresh cloned copy of your repository? – VonC Mar 14 '21 at 16:29
  • I created a new cloned repository and tried the same command, but the result is the same. Just returning `Python`. – somia Mar 15 '21 at 06:11
  • @somia Did you install it as in https://superuser.com/a/1589985/141? – VonC Mar 15 '21 at 06:16
  • No. I installed Scoop (package manager for Windows) first and then installed git filter-repo with the command `scoop install git filter-repo` .(which was recommended way for windows to install git filter-repo) But I was a bit afraid that git filter-repo may not be installed correctly because I got a kind of warning while installing it. I'm thinking I should try another way as the link you cited. – somia Mar 15 '21 at 06:39
  • I think I should post a new question about this. I would post new one and add the link. Thank you for recommending me `git-filter-repo`. – somia Mar 15 '21 at 07:23