How to grep search in modified files of working directory which are not yet been staged(indexed)?

It seems git grep doesn’t have any option to search only in working directory modified files prior to indexing those files. is there any native git command for this purpose or should I use a combo git/linux commands?

  • What is a git topic branch?
  • Git - remote: fatal: You are on a branch yet to be born
  • .ssh config with amazon ec2 and git
  • git apply a patch as much as possible when failing
  • How to integrate Clearcase developpement history into Git?
  • Undo a git merge when it has been pushed
  • `git clean` removes ignored files by default?
  • How to set up a Git hook so that after pushing to ssh://, it will go to ~/ and do a git pull?
  • How do I git rebase the first commit?
  • File content in Sublime does not change on Git branch change
  • Making commits simpler in Git using PowerShell
  • Remove duplicate commits introduced after bad rebase(s)
  • 2 Solutions collect form web for “How to grep search in modified files of working directory which are not yet been staged(indexed)?”

    by using linux grep and git ls-files:

    $ grep -s "search pattern" $(git ls-files -m)

    note 1: grep’s -s option is provided for Suppress error messages about nonexistent or unreadable files because git ls-files -m lists deleted files too which causes grep give "No such file or directory" error when encounters a nonexistent file.

    note 2: git ls-files’ -m option is for listing only modified files(which also lists removed files too!)

    git grep is modelled on plain grep, perhaps you should just use that.

    Git Baby is a git and github fan, let's start git clone.