GIT-SED(1)
π GIT-SED(1) β the Git Extras era
okay bestie, sit down, because git-sed is about to become your new obsession β¨
πΈ NAME πΈ
git-sed β swap out patterns inside files that git is tracking, no cap π¦
β¨ SYNOPSIS β¨
git-sed [ -c ] [ -f flags ] search replacement [ flags ] [ -- pathspec ]
π DESCRIPTION π
so here's the vibe: it runs git grep, takes whatever it found, and hands those results straight to sed so your patterns get replaced β with the flags you gave it, if you gave it any (either through -f or as that third argument, iykyk).
and if you pass -c? it also runs git commit for you. main character behavior, honestly π
π OPTIONS π
-cβ commits the changes that come out of this, using a standard commit message that spells out the exact command you ran. β οΈ it will fail if there are unstaged changes, so tidy up first bestie.<flags> -f <flags>β uses these regex flags in thesedcommand. for example"g"replaces multiple times on the same line. (you can pass<flags>bare as the third argument too.)<search>β the pattern that gets passed togrepand to the first part of thesedexpression.<replacement>β the replacement that gets passed tosed, aka the second part of thesedexpression.-- <pathspec>β limits which paths this gets applied to. for the supported patterns of pathspec, go read <https://git-scm.com/docs/gitglossary.html#Documentation/gitglossary.txt-aiddefpathspecapathspec> π
π EXAMPLES π
$ git sed 'my_function' 'do_stuff'
# ... only does the changes, without committing
$ git commit -m"use proper function name"
$ git sed -c 'do_stuff' 'stuff'
# .. does the changes and a commit
$ git sed -f g do_stuff stuff
# .. g is actually pretty important, otherwise you will miss some
# stuff!
$ git sed 'my_method' 'do_stuff' -- lake/
# ... only replace 'my_method' occurs under lake/.
π AUTHOR π
written by Antoine BeauprΓ© <anarcat@debian.org>, who was inspired by <https://github.com/da-x/git-search-replace> and <https://stackoverflow.com/questions/9651898/is-there-a-git-sed-or-equivalent> β absolute legends, fr fr π
π REPORTING BUGS π
found something cursed? scream into the void here: <https://github.com/tj/git-extras/issues>
π«Ά SEE ALSO π«Ά
and that's the whole page, angel π this lil' masterpiece shipped in May 2026 as part of Git Extras β go forth and replace patterns responsibly, and remember: no -c without a clean working tree π§β¨
π¦ where this page comes from
- ubuntu stonking: git-extras 7.5.0-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms