diff options
| author | Christian Cleberg <[email protected]> | 2024-03-29 01:30:23 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2024-03-29 01:30:23 -0500 |
| commit | 07c42d3ad17060131e822f5816d2057cd1753b1b (patch) | |
| tree | 205e844650144648e58700df2b632c89298904d4 /blog/changing-git-authors/index.org | |
| parent | c71a52cb7a80a102e58bd5465e994225ea98c44f (diff) | |
| download | cleberg.net-07c42d3ad17060131e822f5816d2057cd1753b1b.tar.gz cleberg.net-07c42d3ad17060131e822f5816d2057cd1753b1b.tar.bz2 cleberg.net-07c42d3ad17060131e822f5816d2057cd1753b1b.zip | |
massive re-write from org-publish to weblorg
Diffstat (limited to 'blog/changing-git-authors/index.org')
| -rw-r--r-- | blog/changing-git-authors/index.org | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/blog/changing-git-authors/index.org b/blog/changing-git-authors/index.org deleted file mode 100644 index b06660d..0000000 --- a/blog/changing-git-authors/index.org +++ /dev/null @@ -1,72 +0,0 @@ -#+title: Changing Git Authors -#+date: 2021-05-30 -#+description: A guide to change Git author names and emails in old commits. -#+filetags: :dev: - -* Changing Git Author/Email Based on Previously Committed Email -Here's the dilemma: You've been committing changes to your git -repository with an incorrect name or email (or multiple repositories), -and now you want to fix it. Luckily, there's a semi-reliable way to fix -that. While I have never experienced issues with this method, some -people have warned that it can mess with historical hashes and integrity -of commits, so use this method only if you're okay accepting that risk. - -Okay, let's create the bash script: - -#+begin_src sh -nano change_git_authors.sh -#+end_src - -The following information can be pasted directly into your bash script. -The only changes you need to make are to the following variables: - -- =OLD_EMAIL= -- =CORRECT_NAME= -- =CORRECT_EMAIL= - -#+begin_src sh -#!/bin/sh - -# List all sub-directories in the current directory -for dir in */ -do - # Remove the trailing "/" - dir=${dir%*/} - # Enter sub-directory - cd $dir - - git filter-branch --env-filter ' - - OLD_EMAIL="[email protected]" - CORRECT_NAME="your-new-name" - CORRECT_EMAIL="[email protected]" - - 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 - - git push --force --tags origin 'refs/heads/*' - - cd .. -done -#+end_src - -Finally, save the bash script and make it executable. - -#+begin_src sh -chmod a+x change_git_authors.sh -#+end_src - -Now you can run the script and should see the process begin. - -#+begin_src sh -./change_git_authors.sh -#+end_src |
