Skip to content

dev-kraken/mirror_repo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Git Repository Mirroring Script

Overview

This Bash script automates the process of mirroring a Git repository while updating author and committer email addresses in the commit history. It is useful for transferring a repository to a new remote location and ensuring that the commit history reflects the correct author information.

Features

  • User Input Prompts: The script prompts the user for essential information:

    • Repository URL to clone
    • Old email address to change
    • New email address to use
    • Correct name associated with the new email
    • New repository URL for mirroring
  • Repository Cloning: Uses git clone --mirror to create a bare clone of the specified repository, including all branches and tags.

  • Commit History Modification: Utilizes git filter-branch to update author and committer details in the commit history based on user input.

  • Remote URL Update: Updates the remote origin URL to point to the new repository after modifying the commit history.

  • Push Changes: Pushes all branches and tags from the local mirror to the new remote repository using git push --mirror.

Usage Instructions

Prerequisites

  • Ensure that Git is installed on your system.
  • Make sure you have access rights to both the original and new repositories.

Steps to Execute

  1. Save this script mirror_repo.sh or
curl --O https://raw.githubusercontent.com/dev-kraken/mirror_repo/main/mirror_repo.sh
  1. Make it executable by running:
chmod +x mirror_repo.sh 
  1. Execute the script by running:
./mirror_repo.sh
  1. Follow the prompts to enter the required information.

Example Scenario

Suppose you have a Git repository hosted on GitHub with an old email address associated with your commits. You want to migrate this repository to a new location (e.g., another GitHub account or a different platform) while correcting your email address in all past commits. This script simplifies that process by handling everything in one go.

Important Notes

  • This script is designed for use in environments that support Bash (e.g., Linux, macOS, Windows with Git Bash).
  • The use of git filter-branch may take some time depending on the size of your repository and its commit history.
  • After running this script, ensure you verify that all changes have been applied correctly in your new remote repository.

About

Git Repository Mirroring and Email Update

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages