# protect .git folder/files from grep/sed commands

2 messages from 2019-03-16 to 2019-03-16. Participants: Dimitri Joukoff, SZEDER Gábor.
Thread: https://gitlist.dev/t/50752

## Dimitri Joukoff, 2019-03-16 01:37

Subject: protect .git folder/files from grep/sed commands
Message-ID: <SYXPR01MB09574FEB4E6D6476B4F1D155DD450@SYXPR01MB0957.ausprd01.prod.outlook.com>
URL: https://gitlist.dev/e/SYXPR01MB09574FEB4E6D6476B4F1D155DD450%40SYXPR01MB0957.ausprd01.prod.outlook.com

```
When performing global changes in a project/tree using a command like:

grep -r "search" | xargs -I {} sed -i '' s/search/replace/g

there exists the possibility that this command will alter data in .git
folder.  Using GNU grep, it is possible to use --exclude '/.*"' to avoid
the .git folder, but this flag is not available on BSD grep (i.e. MacOS).

Maybe git and the .git folder within a repository should be configured
to use a separate user account, and then the .git folder would have its
permissions set to 600?




```

## SZEDER Gábor, 2019-03-16 01:51

Subject: Re: protect .git folder/files from grep/sed commands
Message-ID: <20190316015115.GB24175@szeder.dev>
URL: https://gitlist.dev/e/20190316015115.GB24175%40szeder.dev
In-Reply-To: <SYXPR01MB09574FEB4E6D6476B4F1D155DD450@SYXPR01MB0957.ausprd01.prod.outlook.com>

```
On Sat, Mar 16, 2019 at 01:37:39AM +0000, Dimitri Joukoff wrote:
> When performing global changes in a project/tree using a command like:
> 
> grep -r "search" | xargs -I {} sed -i '' s/search/replace/g
> 
> there exists the possibility that this command will alter data in .git
> folder.  Using GNU grep, it is possible to use --exclude '/.*"' to avoid
> the .git folder, but this flag is not available on BSD grep (i.e. MacOS).

Try 'git grep "search" | ...'


```
