Changing author info

 https://help.github.com/articles/changing-author-info/
 

To change the name and/or email address recorded in existing commits, you must rewrite the entire history of your Git repository.

Warning: This action is destructive to your repository's history. If you're collaborating on a repository with others, it's considered bad practice to rewrite published history. You should only do this in an emergency.

Changing the Git history of your repository using a script

We've created a script that will change any commits that previously had the old email address in its author or committer fields to use the correct name and email address.

Note: Running this script rewrites history for all repository collaborators. After completing these steps, any person with forks or clones must fetch the rewritten history and rebase any local changes into the rewritten history.

Before running this script, you'll need:

  • The old email address that appears in the author/committer fields that you want to change
  • The correct name and email address that you would like such commits to be attributed to

  1. Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).

  2. Create a fresh, bare clone of your repository:

    git clone --bare https://github.com/user/repo.git
    cd repo.git
  3. Copy and paste the script, replacing the following variables based on the information you gathered:

    • OLD_EMAIL
    • CORRECT_NAME
    • CORRECT_EMAIL
      #!/bin/sh
      
      git filter-branch --env-filter '
      
      OLD_EMAIL="your-old-email@example.com"
      CORRECT_NAME="Your Correct Name"
      CORRECT_EMAIL="your-correct-email@example.com" if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
      then
      export GIT_COMMITTER_NAME="$CORRECT_NAME"
      export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
      fi
      if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
      then
      export GIT_AUTHOR_NAME="$CORRECT_NAME"
      export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
      fi
      ' --tag-name-filter cat -- --branches --tags

        

  4. Press Enter to run the script.
  5. Review the new Git history for errors.
  6. Push the corrected history to GitHub:

    git push --force --tags origin 'refs/heads/*'
    
  7. Clean up the temporary clone:

    cd ..
    rm -rf repo.git

如何修改Github上提交的错误用户地址和姓名的更多相关文章

  1. 修改Github上提交日志

    bash: git rebase -i HEAD~5:假定你要修改的日志位于当前版本(HEAD)的前4次提交中. vi: pick -> reword:在自动打开的vi编辑器中,上下选择你要修改 ...

  2. Git安装配置和提交本地代码至Github,修改GitHub上显示的项目语言

    1. 下载安装git Windows版Git下载地址: https://gitforwindows.org/ 安装没有特别要求可以一路Next即可,安装完成后可以看到: 2. 创建本地代码仓库 打开G ...

  3. 如何在github上提交pr

    如何在github上提交pr 1.fork开源的代码到自己的远程仓库 2.clone自己的仓库到本地电脑 3.与源代码的github仓库建立新的连接 git remote add upstream h ...

  4. 命令行将本地代码上传到github及修改github上代码

    第一步:建立git仓库 cd到你的本地项目根目录下,(这是我的细目目录) 执行git命令 git init 第二步:将项目的所有文件添加到仓库中 git add . 如果想添加某个特定的文件,只需把. ...

  5. 向github上提交自己的project

    参考博客:https://blog.csdn.net/m0_37725003/article/details/80904824 step I: 创建自己的github账户(username:fourm ...

  6. 新手小白如何向GitHub上提交项目

    首先你得注册一个自己的GitHub账号,注册网址:https://github.com/join 创建一个新的项目,填写项目名称,描述 创建完成之后,跳转到下面的页面,下面红框中的网址要记住,在后面上 ...

  7. 修改GitHub上项目语言显示的问题

    问题 最近将自己写的博客放到github上了.由于使用了富文本编辑器.jQuery.Bootstrap等第三方插件,导致js.css等代码远远超过你自己写的代码. 于是也就成这样了 而且这里也显示Ja ...

  8. 修改GitHub上项目语言显示

    问题 最近将自己以Scala为主语言写的博客放到github上了.由于使用了富文本编辑器.jQuery.Bootstrap等第三方插件,导致js.css等代码远远超过你自己写的代码. 于是也就成这样了 ...

  9. [转]修改github已提交的用户名和邮箱

    改变作者信息 为改变已经存在的 commit 的用户名和/或邮箱地址,你必须重写你 Git repo 的整个历史. 警告:这种行为对你的 repo 的历史具有破坏性.如果你的 repo 是与他人协同工 ...

随机推荐

  1. 【[SDOI2009]晨跑】

    板子 题意就是每个点只能经过一次 所以非常显然拆点,除去\(1,n\)每个点\(i\)向\(i'\)连一条容量为\(1\)费用为\(0\)的边 剩下的边按照输入给出的建就好了 代码 #include& ...

  2. hack-checkbox

    checkbox选择按钮要用我们自己的样式,看到这个的时候,很可能会以为需要checkbox才能实现,用css可能很难.其实狠简单. <style> .checkbox input{ di ...

  3. 解决adb devices无法连接夜神模拟器

    打开命令cmdadb connect 127.0.0.1:62001

  4. Markdown黑色背景代码高亮

    因为我默认的不是Markdown...这里分享给用Markdown的小伙伴吧. /* 使用了Monokai Sublime的黑色主题皮肤,但是还存在样式冲突,需要自己修改 这个样式只适合使用maked ...

  5. c语言描述的二叉树的基本操作(层序遍历,递归,非递归遍历)

    #include<stdio.h> #include<stdlib.h> #define OK 1 #define ERROR 0 #define TRUE 1 #define ...

  6. android 网络技术基础学习 (七)

    使用httpclient协议访问网络: public class MainActivity extends Activity implements OnClickListener{ public vo ...

  7. MarkDown/Html在线转换(支持代码高亮,可复制到微信公众号、今日头条)

    MarkDown/Html在线转换能够将md渲染成html并且能保持代码高亮,可以方便的复制待格式的html粘贴到微信公众号,CSDN,简书,博客园,开源中国等. 扫码体验在线助手小程序 我是java ...

  8. html+css让网页自动适应手机屏幕

    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scal ...

  9. File zilla远程连接服务器报错:服务器发回了不可路由的地址,使用服务器地址代替

    百度的答案都是:更改Filezilla设置,编辑-设置-连接-FTP-被动模式,将“使用服务器的外部ip地址来代替”改为“回到主动模式”即可.但问题没有解决!!! 由于使用的是阿里云的服务器.安全组里 ...

  10. iOS之报错“Cannot create __weak reference in file using manual reference counting”解决办法

    解决的办法:在Build Settings--------->Aplle LLVM8.0 - Language - Objectibe-C------------->Weak Refere ...