SaveSnippets
Community
Pricing
Sign In
Get Started
Community
Public Snippets
8
Code shared by the SaveSnippets community — browse, copy, and get inspired.
All Languages
Bash
Go
HTML
Java
JavaScript
Kotlin
PHP
Python
Rust
SQL
TypeScript
#git
Clear
Tags
#php
#kotlin
#bash
#go
#sql
#rust
#typescript
#html
#java
#python
#files
#utils
#strings
#http
#concurrency
#async
#json
#arrays
#security
#types
#crypto
#database
#dates
#format
Bash
Clean Up Merged Branches
Delete every local branch that's been merged to main. Filters out main/master and the current branch as a safety net.
#bash
#git
#cleanup
#branches
Bash
List Authors by Commit Count
Quick repo stats: who has done what. Add --no-merges if you don't want to count merge commits.
#bash
#git
#stats
#shortlog
Bash
Stash With a Message
`git stash` without args is hard to grep through later. Always pass a message — your future self will thank you.
#bash
#git
#stash
#workflow
Bash
Show Current Branch in Prompt
Append the git branch to your bash prompt. Survives non-git dirs gracefully (just shows nothing). Drop into ~/.bashrc.
#bash
#git
#prompt
#ps1
Bash
Most-Modified Files in Repo
Find the hottest files in a git history — useful for spotting hotspots that need refactoring or extra test coverage.
#bash
#git
#log
#hotspots
Bash
Squash Last N Commits
Combine the last N commits into one before merging a feature branch. Avoids hours of "WIP" / "fix typo" commits cluttering history.
#bash
#git
#rebase
#squash
#history
Bash
Reset Branch to Match Remote
Throw away local commits and resync to origin. Destructive — make sure no local work is at risk first.
#bash
#git
#reset
#clean
#danger
Bash
Find Commit That Introduced a String
`git log -S` (the "pickaxe") finds commits whose diff added or removed a given string. The fastest way to answer "when did this line first appear?"
#bash
#git
#log
#pickaxe
#blame