由另一个GitHub帐户错误地推送到GitHub [英] Push to GitHub mistakenly done by another GitHub account

查看:49
本文介绍了由另一个GitHub帐户错误地推送到GitHub的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 a 的本地存储库,该存储库已经与GitHub帐户 A-github 的一个名为 A 的远程存储库相关联,而且我还有一个名为 b 的本地存储库,该存储库尚未与任何远程存储库关联.

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.

我创建了一个新的远程存储库,名为GitHub帐户 B-github B ,我尝试从中首次推送到 B 本地存储库 b .

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.

  • 推送成功,我看到 B 的页面反映了 b 的提交.
  • 但是,完成显示在 B 页面上的第一次推送的用户的名称不是 b 的名称,而是另一个GitHub的名称.帐户 A-github .(图标图像也与 A-github 页面中设置的图像相同)
  • 然后,当我单击首次按下的用户的名称( A-github )时,我转到了 A-github 帐户的页面.
  • 奇怪的是,这种情况没有记录在 A-github 的概述"页面上的"贡献活动"上.
  • 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.

我猜这是本地存储库 b git config 的问题.我尝试了 git config -l <​​/code>,发现 user.name user.email 像这样加倍了:

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

我想让git使用合适的用户( b )推送到 B ,如果可以,我想取消进行的推送A-github

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

我该怎么办?

我已经通过软件包管理器安装了 git filter-repo ,并尝试了

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

使用 git filter-repo --mailmap my-mailmap 格式为

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

然后,按Enter键.但是,结果是刚返回的外壳程序

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.

我担心我正确使用了 git filter-repo .

我的理解是,我首先需要创建一个文本文件,其格式如下:

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

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

其中正确的名称< 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.

可以吗?

我发现似乎我需要预先在PC上安装Python才能使用 git-filter-repo 命令,因此前一阵子我通过Scoop安装了Python.我再次尝试执行上面的命令,并且这次外壳返回:

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

另一个困难来了.

现在讨论已从该主题开始,我发布了一个新问题,我将结束这个问题.感谢您的建议.

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

推荐答案

首先,在存储库中执行 git config -l --show-scope --show-origin :这样,您一定会看到什么是本地配置,它会覆盖全局配置.

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.

第二,您可以使用 git filter-repo 更改提交的用户名/电子邮件在repoB中:然后您将需要对其进行 git push --force (如果您独自在该新存储库上工作,这不是一个大问题).

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

这篇关于由另一个GitHub帐户错误地推送到GitHub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆