LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-sed

Find and replace across tracked files

TLDR

Find and replace in tracked files
$ git sed "[old]" "[new]"
copy
Replace with sed flags (e.g. case-insensitive)
$ git sed -f [i] "[old]" "[new]"
copy
Limit to a path
$ git sed "[old]" "[new]" -- [path/]
copy
Replace and commit the result
$ git sed -c "[old]" "[new]"
copy

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
copy
sudo dnf install git
copy
sudo pacman -S git
copy
sudo apk add git
copy
sudo zypper install git
copy
brew install git
copy
nix profile install nixpkgs#git
copy

SEE ALSO

sed(1), git-grep(1), git-extras(1)

RESOURCES

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid