Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dmelechow/18c174b5f8d919a6fddb23c954837167 to your computer and use it in GitHub Desktop.

Select an option

Save dmelechow/18c174b5f8d919a6fddb23c954837167 to your computer and use it in GitHub Desktop.
git commands for working with branches history
# Remove all megred branches locally
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
# Remove all local branch if there is no origin version. (It means remote branch was merged and removed)
for local_branch in $(git branch);
do
if ! git branch -r | grep "origin/$local_branch" &>/dev/null; then
git branch -D "$local_branch"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment