Provides a new git command, git xargs
, that runs an arbitrary shell command on
all files under source control. Optionally you can specify a pathspec (such as a
subpath or a glob expression), restricting the operation to a subset of the
repository files.
As git xargs
delegates the work to xargs(1)
, it supports all options provided by the version of xargs
installed on your system.
After running
curl -sL https://gist.githubusercontent.com/pesterhazy/65360ed980ae0c86a4150102ca6484a0/raw/git-xargs | \
sudo tee /usr/local/bin/git-xargs > /dev/null && \
sudo chmod +x /usr/local/bin/git-xargs
in your shell and making sure that /usr/local/bin
is on your PATH, git
will automatically detect git xargs
.
git xargs [xargs-options] [<command> <args>]
git xargs [<file>...] -- [xargs-options] [<command> <args>]
-
git xargs du -c
shows total disk usage of files under source control
-
git xargs -n1 echo
equivalent to git ls-files
-
git xargs '*.cpp' '*.c' -- sed -i '' 's/foo/bar/g'
replace string foo with string bar in all c and cpp fles under source control
-
git xargs rpl foo bar
simpler way to do the same. This requires installation of rpl(1).