Undo “git add ”?

I mistakenly added files using the command “git add dir”. I have not yet run “git commit”. Is there a way to remove this dir and everything contained within it from the commit? I have tried git reset dir, but it didn’t work. Apparently git reset file is the way to undo it. But I … Read more

How can I move HEAD back to a previous location? (Detached head) & Undo commits

In Git, I was trying to do a squash commit by merging in another branch and then resetting HEAD to the previous place via: git reset origin/master But I need to step out of this. How can I move HEAD back to the previous location? I have the SHA-1 fragment (23b6772) of the commit that … Read more

Git: can’t undo local changes (error: path … is unmerged)

I have following working tree state $ git status foo/bar.txt # On branch master # Unmerged paths: # (use “git reset HEAD <file>…” to unstage) # (use “git add/rm <file>…” as appropriate to mark resolution) # # deleted by us: foo/bar.txt # no changes added to commit (use “git add” and/or “git commit -a”) File … Read more