iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🤖
How to use git commands in containerized jobs in GitHub Actions
Overview
When starting a job using a container in GitHub Actions, using commands like git fetch within that job causes the following error:
fatal: detected dubious ownership in repository at '/__w/xxxxx/xxxxx'
To add an exception for this directory, call:
git config --global --add safe.directory /__w/xxxxx/xxxxx
Error: Process completed with exit code 128.
This is also discussed in the issue below:
This occurs because the set-safe-directory: true default setting in actions/checkout is not carried over into the container.
There are reports that updating the Git version also resolves this, but since I couldn't modify the container I was using in this case, I addressed it by manually configuring set-safe-directory.
I am running the following step before using git commands:
run: git config --global --add safe.directory /__w/< GitHub repository name >/< GitHub repository name >
Related Links
Discussion