I know I can use the -n
flag in git grep
to show the line numbers of the results, i.e
git grep -n "some string"
but how could I include this flag by default without making an alias? I found git config --global grep.lineNumber true
but it doesn't seem to be working for me.
To Display Line Numbers with grep MatchesAppend the -n operator to any grep command to show the line numbers. We will search for Phoenix in the current directory, show two lines before and after the matches along with their line numbers.
`git grep` command is used to search in the checkout branch and local files. But if the user is searching the content in one branch, but the content is stored in another branch of the repository, then he/she will not get the searching output.
git grep "string to search" -> Will search the string in the complete code base. git grep -ni "string to search" -> Will list the matches without considering the case of string along with line numbers. git grep --break "search string" -> Will list the matches from different files with a line break in between.
From the git grep manual:
Options: -n, --line-number Prefix the line number to matching lines.
Configuration: grep.lineNumber If set to true, enable -n option by default.
To turn on globally: git config --global grep.lineNumber true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With