Skip to content

Instantly share code, notes, and snippets.

@stefan-girlich
Last active March 7, 2018 16:08
Show Gist options
  • Save stefan-girlich/2214eb9340f38cdc776e826895c204b5 to your computer and use it in GitHub Desktop.
Save stefan-girlich/2214eb9340f38cdc776e826895c204b5 to your computer and use it in GitHub Desktop.
Cleans up your Git working directory, e. g. after completing a merge request
#!/bin/sh
# Save file in executable PATH, e. g. /usr/bin
# Usage: "git fullclean"
git checkout develop
git pull --rebase
git fetch --prune
BRANCHES_TO_KEEP_REGEX="(^\*|master|develop)"
git branch --merged|egrep -v $BRANCHES_TO_KEEP_REGEX|xargs git branch -d
# also erases untracked files
# git clean -f -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment