Skip to content

Instantly share code, notes, and snippets.

@damianpumar
Created June 8, 2024 14:50
Show Gist options
  • Save damianpumar/9b6e1ac3c5dbd4258763f056e7e8ca3d to your computer and use it in GitHub Desktop.
Save damianpumar/9b6e1ac3c5dbd4258763f056e7e8ca3d to your computer and use it in GitHub Desktop.
Clear commits and push
HASH=$(git commit-tree HEAD^{tree} -m "🚀 First commit")
git reset $HASH
echo "🚀 First commit has been cleared"
sleep 0.2
echo "Pushing to the current branch"
BRANCH=$(git rev-parse --abbrev-ref HEAD)
git push origin -f $BRANCH
@damianpumar
Copy link
Author

If you want to clear all commits in your current branch, just execute this bash script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment