Interview Prep/Git & GitHub/Config, Line Endings, Files and Platform Quirks

A deploy script run with `sudo -u deploy git pull` prints `warning: unable to access '/root/.config/git/attributes': Permission denied`.

IntermediateTroubleshootingConfig, Line Endings, Files and Platform Quirks
Answer

Likely causes → sudo changed the user but kept HOME=/root, so Git, now running as deploy, tries to read root's config files and fails. It may also ignore the deploy user's real config (credentials, safe.directory).

Diagnose → sudo -u deploy env | grep ^HOME

Fix → Reset HOME to the target user:

sudo -H -u deploy git -C /srv/app pull --ff-only
# or: sudo -iu deploy git -C /srv/app pull --ff-only

Prevent → Run deploy commands as the service user via a systemd unit or CI agent rather than ad-hoc sudo.

All Git & GitHub questions Roadmap: Git & GitHub

More on Config, Line Endings, Files and Platform Quirks