Posts Tagged ‘ ci/cd

Git: warning: Not a git repository

When you try to update/pull or get a diff for the Git repository, you can get a warning:

warning: Not a git repository. Use --no-index to compare two paths outside a working tree
usage: git diff --no-index [<options>] <path> <path>

It is because the new version of Git forbidden to run git commands in a directory that is not owned by the current user ( CVE-2022-24765 )

To fix, you need to change permission for the directory or set security options to git when running commands in CI/CD

git config --global --add safe.directory $(pwd)