Skip to content

Instantly share code, notes, and snippets.

@ulgens
Created June 16, 2026 12:43
Show Gist options
  • Select an option

  • Save ulgens/3e739471c5c6b802a85515ea72bf98da to your computer and use it in GitHub Desktop.

Select an option

Save ulgens/3e739471c5c6b802a85515ea72bf98da to your computer and use it in GitHub Desktop.
# Delete merged branches
git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done
# Update origin from upstream
git fetch upstream && git checkout main && git merge upstream/main
# ^Same thing but for dinosaurs
git fetch upstream && git checkout master && git merge upstream/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment