inspired from @VonC I came to this script:
(brew install git-filter-repo
is needed)
#!/bin/bash
# Create a temporary file to store the commit messages
temp_file=$(mktemp)
main_head_hash=$(git rev-parse main)
suffix="⚠️ rebased since!"
# Use git log to retrieve the commit messages and store them in the temporary file
git log --pretty=format:%s $main_head_hash.. | grep -v $suffix | grep ' build version' > $temp_file
# Create a file to store the replacements
echo > replacements.txt
# Iterate over the commit messages in the temporary file
while read commit_message; do
# Print the replacement message to the replacements.txt file
echo "$commit_message==>$commit_message $suffix" >> replacements.txt
done < $temp_file
# ⚠️⚠️ Rewriting history ⚠️⚠️
git filter-repo --replace-message replacements.txt --force
# Remove the temporary files
rm $temp_file
rm replacements.txt
(The script was made with help of chatGPT - giving it clear instructions on what steps to write a script for. I'm aware of the temp. ban policy of chatGPT and hope this does not appear as an policy violation since the answer is not solely based of it, but derived from a conversation with trail and error - the script is verified to work and I hope that it will help others)
