Suppose I've removed the text 'foo' from a lot of files in my repository, and I want to commit that change.
But there are also lots of unrelated changes.
How do I find just those files and stage them?
Suppose I've removed the text 'foo' from a lot of files in my repository, and I want to commit that change.
But there are also lots of unrelated changes.
How do I find just those files and stage them?
Copyright © 2021 Jogjafile Inc.
git grep's--cachedoption appears to search in changes that are UNstaged (which looks like a bug, as it's not what its docs say, and it's not howgit difftreats its--cachedoption).Doing
git grep --cached foogets:To stage these, use
cutto extract just the filenames:git grep --cached foo | cut -d : -f 1:and then xargs to stage that list:
git grep --cached foo | cut -d : -f 1 | xargs git add.