Skip to main content
Home
Techies Briefcase
~ by Hari Venu

Main navigation

  • Home
  • Tools
    • Placeholder Image
    • JSON Diff
    • QR Code Generator
    • Random String Generator
    • HTML to PDF Generator
  • About me
  • Photos
  • Search

Breadcrumb

  1. Home
  2. Rewrite The Author's or Committer's Name/email In Past Commits In Git

Rewrite the author's or committer's name/email in past commits in Git

By hari, 19 December, 2022

Sometime you accidentally commit with wrong name/email in Git, after a while you realise the mistake, so you required to change the name/email of the all the commits.

The git-filter-branch is the saviour, but before going with solution you have to read  SAFETY and PERFORMANCE

Specifically, you can rewrite all the wrong author names and emails for all branches and tags with this command


#!/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

Set the OLD_EMIAL, CORRECT_NAME and CORRECT_EMAIL then execute

After done this do a force push

Be Carefull, You should take backup of your repository

Reference
  • https://stackoverflow.com/questions/750172/how-do-i-change-the-author-and-committer-name-email-for-multiple-commits
  • https://git-scm.com/docs/git-filter-branch

Tags

  • Git
 

Topics

  • Form API
  • Windows
  • Drupal AI
  • Field API
  • Multilingual
  • JavaScript
  • Errors
  • professional development
  • Entity Query API
  • Mac OS
  • Drush
  • URL
  • Webform
  • Cache
  • Solar Power
  • RSA
  • Moderation
  • Coder
  • Bower
  • WSL2
  • Macbook
  • Lando
  • Permission
  • Bash Script
  • PHPSeclib
  • Articles
  • VSCode
  • Taxonomy
  • Drupal Behavior
  • Ajax API
  • Codesniffer
  • Drupal Console
  • phpcs
  • Solar Panel
  • Composer
  • Docker
  • jQuery
  • SEO
  • NPM
  • Workflow
  • Ubuntu
  • Views
  • Jellyfin
  • SSH
  • PHP
  • Android
  • Git
  • Twig
  • website
  • Neuron AI
  • MySQL
  • OOPs
  • kali
  • Commad Line Tools
  • Commad Line
  • Libraries
  • File API
  • Learning
  • Nginx
  • phpcbf
  • Drupal
  • Distribution
  • Linux
RSS Feed

Who am I !!!

Hari Venu V
harivenu.v1992@gmail.com
Mobile : +91 9895164181
Whatsapp : +91 9895164181
Linkedin
Drupal.org
Github

Document
Resume.pdf (114.38 KB)

Online Resume : Online Resume

Work !!!

Fulltime Developer @ QED42
hari.venu@qed42.com
Linkedin

Powered by Drupal & Maintained by Hari