The officially official Devuan Forum!

You are not logged in.

#1 2024-09-27 02:04:03

zapper
Member
Registered: 2017-05-29
Posts: 967  

Anyone know how to use git to search?

Like for instance, anyone know commands to search throughout an entire source code for all mentions of python, or in my case python2.7

So I  can find and make corrections.

In all files I might add within source code.

Last edited by zapper (2024-09-27 02:04:29)


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD
Peace Be With us All!

Offline

#2 2024-09-27 02:45:41

quickfur
Member
Registered: 2023-12-14
Posts: 431  

Re: Anyone know how to use git to search?

Are you talking about just grepping the current commit, or are you talking about finding *all* occurrences of something including historical occurrences that no longer exist in the current commit?

Offline

#3 2024-09-27 02:51:18

quickfur
Member
Registered: 2023-12-14
Posts: 431  

Re: Anyone know how to use git to search?

For the former, just a regular grep will do, maybe with -r if you want to recursively grep everything:

grep -r my_regex ./*

For the latter, `git grep` is your friend:

git grep my_regex $(git rev-list --all)

Offline

#4 2024-09-28 23:37:18

zapper
Member
Registered: 2017-05-29
Posts: 967  

Re: Anyone know how to use git to search?

@quickfur I found one also recently, I am not sure if the 2nd you have works, but I found this:

git rev-list --all | xargs git grep -F python2.7

This one works for sure.

EDIT: your 2nd one also works.

The first one doesn't though last I tried it.

Last edited by zapper (2024-09-28 23:41:25)


Freedom is never more than one generation away from extinction. Feelings are not facts
If you wish to be humbled, try to exalt yourself long term  If you wish to be exalted, try to humble yourself long term
Favourite operating systems: Hyperbola Devuan OpenBSD
Peace Be With us All!

Offline

Board footer