[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

rewriting the entire git history... how?



I want to rewrite git history from the very first commit (which is an empty commit) but nothing I can find seems to let me do this other than with manual intervention.

This is a one off and doesn't need to be efficient so long as I can leave it to get on with it without intervention.

This is what I have: (private-email is a place holder)

===
#!/bin/bash

for commit in $( git rev-list --all --reverse master ); do
  git cherry-pick --strategy-option=theirs $commit

  echo "running sed"
  sed -i 's/private-email@woodall.me.uk/builder@woodall.me.uk/g' $( git grep -l 'private-email@woodall.me.uk' )

  GIT_AUTHOR_DATE="$(git show -s --format=%ad HEAD)" GIT_COMMITTER_DATE="$(git show -s --format=%ad HEAD)" git commit -a --amend --reset-author --no-edit --allow-empty
done
===

and this runs for a while but then gets stuck due to a merge conflict (which I thought --strategy-option=theirs would automatically fix)

===
Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
        deleted by them: main/b/bootstrap-apt-gawk/package/debian/control
        deleted by them: main/b/bootstrap-apt-original-awk/package/debian/changelog
        deleted by them: main/b/bootstrap-apt-original-awk/package/debian/control
        deleted by them: main/b/bootstrap-apt-original-awk/package/debian/copyright
        deleted by them: main/d/dpkg-conffile-test/package/debian/changelog
        deleted by them: main/d/dpkg-conffile-test/package/debian/control
        deleted by them: main/d/dpkg-conffile-test/package/debian/copyright
        deleted by them: minimal/buster_dpkg_minimal.sh
        deleted by them: minimal/buster_minimal.sh
        deleted by us:   minimal/minimal.sh
        deleted by them: minimal/sid_minimal.sh

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   main/b/bootstrap-required/Makefile
        modified:   main/b/bootstrap-required/package/debian/control
===

The changes not staged are an artifact of my script not aborting when the cherry-pick failed so it still runs the sed command so I get this over and over again:

===
fatal: You are in the middle of a cherry-pick -- cannot amend.
error: Cherry-picking is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: cherry-pick failed
running sed
sed: no input files
===

Does anyone know of a way to do this? I'm expecting it to take a long time hence why I don't want to have to do manual intervention




Reply to: