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

`git config --global ...` fails with `error: could not lock config file /home/dev/.gitconfig: Permission denied` (or `: File exists`).

IntermediateTroubleshootingConfig, Line Endings, Files and Platform Quirks
Answer

Likely causes → "Permission denied": the file (or $HOME) is owned by root, often after sudo git config --global. "File exists": a stale ~/.gitconfig.lock from a crashed Git or tool.

Diagnose →

ls -l ~/.gitconfig ~/.gitconfig.lock 2>/dev/null
echo "$HOME"

Fix →

sudo chown "$USER":"$(id -gn)" ~/.gitconfig
rm -f ~/.gitconfig.lock          # only if no git process is running

Prevent → Never run Git with sudo in your own repos; fix file permissions instead.

All Git & GitHub questions Roadmap: Git & GitHub

More on Config, Line Endings, Files and Platform Quirks