3

I use the following grepcode command to recursively search a large number of git repositories. It prints the path of found files relative to the repository root, how can I print the absolute path of the file rather than repository relative path.

grepcode() { find . -type d -name .git | parallel "cd {.} && git grep --color -I --full-name -i '$@' }

1
  • 1
    A suggestion: Try removing the --full-name option because it makes git-grep consider the project path as its root path. You may need to pass an absolute path to git-grep for it to be able to output that absolute path. So, try to get the absolute path first, combine it with your current relative path (pwd), then combine with the find result. For getting the absolute path, try playing around with this: stackoverflow.com/questions/15798862/what-does-git-rev-parse-do
    – aff
    Oct 17, 2015 at 7:06

0

You must log in to answer this question.

Browse other questions tagged .