Skip to content

Instantly share code, notes, and snippets.

@alexfu
Last active May 13, 2021 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexfu/cfc7480cd317d57eebcbfed3fa3fa578 to your computer and use it in GitHub Desktop.
Save alexfu/cfc7480cd317d57eebcbfed3fa3fa578 to your computer and use it in GitHub Desktop.
git eject
#!/bin/bash
# Bails on current working branch and switches to main
# Install: Place this script anywhere that is in your $PATH and make it executable (chmod +x)
BRANCH_TO_EJECT=$(git rev-parse --abbrev-ref HEAD)
git reset HEAD --hard
git checkout main
git br -D $BRANCH_TO_EJECT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment