Mirror of
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(content): add uncommon git prune command (#174)

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

authored by

Felix Schneider
coderabbitai[bot]
and committed by
GitHub
0ea7cbd9 d6506d04

+17
+17
src/content/docs/blog/uncommon-git-commands.mdx
··· 84 84 85 85 Interactive rebasing is incredibly useful, as other options like `squash`, `break` or even `exec` are available. Just keep in mind that it makes more sense to do this on a branch where only you work to avoid team friction. 86 86 87 + ## Clean up local branches 88 + 89 + When a PR is merged, the branch is usually deleted after it is safely merged into the default branch. But the branch still exists locally. If you want to delete all the local branches, which got deleted in your remote repository, you can run this command in most shells (use `wsl` on Windows): 90 + 91 + ```bash 92 + git fetch -p && git branch -vv | awk '/: gone] / {print $1}' | grep -v '^\*$' | xargs -I{} git branch -d "{}" 93 + ``` 94 + 95 + :::caution 96 + This is a destructive action. Therefore I included a safeguard by using the lowercase `-d` parameter. If your branches are not cleanly merged, git will not delete them. If you are sure you want to delete all those branches no matter what, use `-D` instead. 97 + ::: 98 + 87 99 ## Summary 88 100 89 101 **🛰️ Track Upstream Branch** ··· 95 107 > `git rebase -i HEAD~n` 96 108 > 97 109 > Use this to rewrite history. In the interactive editor, change `pick` to `reword` for any of the last `n` commits you want to modify. 110 + 111 + **🧹 Prune Local Branches** 112 + > `git fetch -p && git branch -vv | awk '/: gone] / {print $1}' | grep -v '^\*$' | xargs -I{} git branch -d "{}"` 113 + > 114 + > A pipeline that identifies local branches whose remote counterparts have been deleted ("gone") and attempts to delete them safely. 98 115 99 116 ## Resources 100 117