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. 4519: [Cqoi2016]不同的最小割

    4519: [Cqoi2016]不同的最小割 Time Limit: 20 Sec Memory Limit: 512 MB Submit: 489 Solved: 301 [Submit][Stat ...

  2. javap(反汇编命令)

    用法: javap <options> <classes> 其中, 可能的选项包括: -help  --help  -?        输出此用法消息 -version     ...

  3. Android学习笔记_46_fragment的简单应用

    Fragments 诞生初衷 http://www.cnblogs.com/TerryBlog/archive/2012/02/17/2355753.html 自从Android 3.0中引入frag ...

  4. Android学习笔记_32_通过WebView实现JS代码与Java代码互相通信

    webview两种实现方法,覆盖onKeyDown()方法 缓存 WebSettings应用注意的几个问题 1.要实现JS代码与Java代码互相通信,需要通过Android的WebView控件,在视图 ...

  5. 菜鸟崛起 DB Chapter 4 MySQL 5.6的数据库引擎

    数据库存储引擎是数据库底层的软件组件,我们平常看不到,但是却与我们操作数据库息息相关.DBMS使用数据引擎进行创建.查询.更新和删除数据操作.不同的存储引擎提供不同的存储机制.索引技巧.锁定水平等功能 ...

  6. MySQL数据库主从(主主)配置

    一.系统环境: centos7.4 (centos 1708) mysql 5.7 master主机的IP地址为192.168.159.50 slave主机的IP地址为192.168.159.51 M ...

  7. Python常用模块之time和datetime

    1.时间的格式化 结构化时间 ##把字符串时间转换成结构化时间 time.strptime("2017-06-21","%Y-%m-%d") ##把结构化时间转 ...

  8. JSONP--解决ajax跨域问题

    JSON和JSONP JSONP和JSON好像啊,他们之间有什么联系吗? JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.对于JSON大家应该是很了解了吧 ...

  9. Recycler实现瀑布流

    (开发环境Android studio) 首先,在开发环境中添加引用(在外层的build.gradle文件下的dependencies里面添加如下引用) implementation 'com.and ...

  10. bootstrap Table动态绑定数据并自定义字段显示值

    第一步:我们在官网下载了bootstrap 的文档,并在项目中引入bootstrap table相关js文件,当然,也要记得引入jquery文件 大概如图: 第二步:定义一个table控件 第三步:j ...