Interview Prep/Git & GitHub/Push, Pull and Fetch Errors

`error: cannot lock ref 'refs/remotes/origin/feature/x': 'refs/remotes/origin/feature' exists; cannot create 'refs/remotes/origin/feature/x'`

IntermediateTroubleshootingPush, Pull and Fetch Errors
Answer

Likely causes → Refs are stored as files, so feature and feature/x cannot coexist. A branch feature was deleted remotely and feature/x created, but your stale remote-tracking ref origin/feature still exists.

Diagnose → git branch -r | grep feature and git ls-remote --heads origin 'feature*'.

Fix → git remote prune origin (or git fetch --prune) and fetch again. Also delete a conflicting local branch if one exists.

Prevent → Agree on branch naming that avoids a name being both a branch and a prefix, and enable fetch.prune.

All Git & GitHub questions Roadmap: Git & GitHub

More on Push, Pull and Fetch Errors