Issue
Trying to do git diff --name-only hash1 hash2
, and it gives something like:
package.json
index.ts
...listing the files.
How do I create a one-liner bash command to then check if it includes package.json
?
git diff --name-only hash1 hash2 | includes package.json
Solution
Use grep like this:
grep -Fxq package.json
-F
turns off regular expression matching sopackage.json
doesn't matchpackageXjson
,packageYjson
, etc.-x
turns off substring matching sopackage.json
doesn't matchXpackage.json
,package.jsonY
, etc.- and
-q
suppresses normal output so you get only whether there is a match or not.
Answered By - oguz ismail Answer Checked By - Cary Denson (WPSolving Admin)