protect .git folder/files from grep/sed commands
- From
- Dimitri Joukoff <dimitri.joukoff@griffithuni.edu.au>
- Date
- Mar 16, 2019, 01:37 UTC
- Message-ID
- <SYXPR01MB09574FEB4E6D6476B4F1D155DD450@SYXPR01MB0957.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/gthere 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?