Skip to content

Instantly share code, notes, and snippets.

@PierreBresson
Last active September 9, 2020 09:38
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 PierreBresson/ccb647a7fdebc254681ab8f03e5bd9d6 to your computer and use it in GitHub Desktop.
Save PierreBresson/ccb647a7fdebc254681ab8f03e5bd9d6 to your computer and use it in GitHub Desktop.
How to auto delete you branch you are currently in with git

Inside .gitconfig at user root, copy the following :

[alias]
	delete-branch = "!sh $HOME/scripts/git_branch_name_to_clipboard.sh"

Still at user root, create a folder name scripts and create it_branch_name_to_clipboard.sh file in it.

Inside it_branch_name_to_clipboard.sh, copy the following :

git branch | grep "*" | awk '{ print $2 }' | pbcopy
git checkout master
git branch -D $(pbpaste)
git pull
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment