`fatal: Cannot do hard reset with paths.`
BeginnerTroubleshootingLost Work, HEAD and History Problems
Answer
Likely causes → You tried git reset --hard <file>. Hard reset works on the whole tree, not on single paths.
Diagnose → Re-read your command: path arguments are only allowed with mixed or soft modes.
Fix → To restore one file to HEAD: git restore --source=HEAD --staged --worktree path/to/file. To restore from another commit: git restore --source=<sha> path. To unstage only: git reset path or git restore --staged path.
Prevent → Use git restore for files and git reset for branches.
More on Lost Work, HEAD and History Problems
`fatal: Unable to create '/repo/.git/index.lock': File exists.`BeginnerYou added a file to `.gitignore`, but `git status` still shows it as modified.Beginner`fatal: your current branch 'main' does not have any commits yet`Beginner`Author identity unknown *** Please tell me who you are.` and `fatal: unable to auto-detect email address`Beginner`fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.`BeginnerYour commits do not show on your GitHub profile contribution graph.Intermediate