Giter VIP home page Giter VIP logo

git-author-updater's Introduction

Git Author Updater

This repository contains two simple Bash scripts designed to update the author and committer information in a Git repository. Use these scripts when you need to change your account name or email address and update this information in your previous projects.

Usage

1. update_author_info_by_email

This script updates the author and committer information based on the email address.

Instructions

  • Replace {old_email} with the email address you want to change.
  • Replace {new_username} with the new username.
  • Replace {new_email} with the new email address.

Example

#!/bin/bash
git filter-branch -f --env-filter '
OLD_EMAIL="{old_email}"
CORRECT_NAME="{new_username}"
CORRECT_EMAIL="{new_email}"

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

# Sleep for 3 seconds
sleep 3

2. update_author_info_by_username

This script updates the author and committer information based on the username.

Instructions

  • Replace {old_name} with the username you want to change.
  • Replace {new_name} with the new username.
  • Replace {new_email} with the new email address.

Example

#!/bin/bash
git filter-branch -f --env-filter '
OLD_NAME="{old_username}"
CORRECT_NAME="{new_username}"
CORRECT_EMAIL="{new_email}"

if [ "$GIT_COMMITTER_NAME" = "$OLD_NAME" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_NAME" = "$OLD_NAME" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

# Sleep for 3 seconds
sleep 3

Execution

  1. Place the desired script in your local repository.
  2. Open a terminal in the repository's directory.
  3. Make the script executable
  4. Run the script:
    ./update_author_info_by_email
    or
    ./update_author_info_by_username

Conclusion

These scripts provide a convenient way to update your Git commit history with new author and committer information. By following the instructions and examples provided, you can ensure that your previous projects reflect your current account details accurately.

git-author-updater's People

Contributors

1970mr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.