Skip to content

Instantly share code, notes, and snippets.

@naliferopoulos
Created November 16, 2021 08:55
Show Gist options
  • Save naliferopoulos/63d80a747c33a9c12a7f003ea649f2c7 to your computer and use it in GitHub Desktop.
Save naliferopoulos/63d80a747c33a9c12a7f003ea649f2c7 to your computer and use it in GitHub Desktop.
Unravel a git repository in multiple ones in a historical fashion
#! /bin/bash
# Example: ./unravel.sh myrepo
REPO=$1
BRANCH="master"
count=0
pushd $REPO
for commit in $(git rev-list $BRANCH | tail -r)
do
popd
newrepo="$count-$commit"
cp -r $REPO $newrepo
pushd $newrepo
git reset $commit
git checkout $BRANCH .
$rebasecount=$count+1
git rebase HEAD~$rebasecount
git commit --amend --date=now
popd
(( count++ ))
pushd $REPO
done
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment