Skip to content

Instantly share code, notes, and snippets.

@aldoyh
Created April 25, 2024 21:41
Show Gist options
  • Save aldoyh/5609724c3d3efb54f27a102c2e3630d3 to your computer and use it in GitHub Desktop.
Save aldoyh/5609724c3d3efb54f27a102c2e3630d3 to your computer and use it in GitHub Desktop.
rev-commits
#!/bin/bash
# Clone the original repo
git clone https://github.com/mohammadrz003/moonfo-youtube.git moonfo-youtube-original
# Navigate to the cloned repo
cd moonfo-youtube-original
# Initialize an empty commit history
git reset --hard HEAD
git clean -df
# Apply each commit in reverse order
for i in $(git log -1 --reverse); do
# Get the commit hash and message
COMMIT_HASH=$(git rev-parse $i)
COMMIT_MESSAGE=$(git show -s --format=%B $i)
# Apply the commit changes
git reset --hard $COMMIT_HASH
git apply <(git diff-tree -p $COMMIT_HASH HEAD)
# Print the commit message
echo "$COMMIT_MESSAGE"
done
# Remove the original repo and exit
rm -rf moonfo-youtube-original
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment