git-sed
Find and replace across tracked files
TLDR
Find and replace in tracked files
$ git sed "[old]" "[new]"
Replace with sed flags (e.g. case-insensitive)$ git sed -f [i] "[old]" "[new]"
Limit to a path$ git sed "[old]" "[new]" -- [path/]
Replace and commit the result$ git sed -c "[old]" "[new]"
SYNOPSIS
git sed [-c] [-f flags] search replacement [flags] [-- pathspec]
DESCRIPTION
git sed runs `git grep` to find matching files, then pipes them through `sed -i` to replace `search` with `replacement`, limiting changes to files tracked by Git so untracked or ignored files are never touched. Part of git-extras, it saves the separate `grep | xargs sed` pipeline for repository-wide renames.
PARAMETERS
SEARCH
Pattern to find.REPLACEMENT
Text to substitute in.-f, --flags flags
sed substitution flags to append (e.g. `g`, `i`); may also be given as a trailing positional argument.-c, --commit
Commit the change afterward; fails if the working tree isn't already clean.-- pathspec
Limit the replacement to matching files/paths.
INSTALL
sudo apt install git
sudo dnf install git
sudo pacman -S git
sudo apk add git
sudo zypper install git
brew install git
nix profile install nixpkgs#git
SEE ALSO
sed(1), git-grep(1), git-extras(1)
