Skip to content

Instantly share code, notes, and snippets.

@smuuf
Last active February 23, 2026 14:18
Show Gist options
  • Select an option

  • Save smuuf/c19f6192cb7d870bbcad66549d71cb42 to your computer and use it in GitHub Desktop.

Select an option

Save smuuf/c19f6192cb7d870bbcad66549d71cb42 to your computer and use it in GitHub Desktop.
git tidy-branch
#!/bin/bash
# Put this somewhere in your $PATH and git will automatically use it when you run "git tidy-branch".
echo "■ tidy-branch"
echo "■ Premysl Karbula, 2025"
echo
echo "■ Usage: git tidy-branch <parent branch>"
echo
echo "This will run interactive rebase of the current branch up to the first common commit with the specified parent branch."
echo "You should probably back up your current branch first."
echo
if [[ -z "$1" ]]; then
echo "Error: Parent branch not specified."
exit 1
fi
echo -n "Press CTRL+C to abort or any other key to continue..."
read -r -n 1 -s
echo
git rebase -i `git merge-base HEAD $1`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment