How to do Undo things done mistakenly in GIT

Remove file added to staging for commit

Undo git add command
git checkout -- <filename>

Discard Changes to added file to staging

git checkout <filename>; i.e. checkout repository's version

Undo last commit

git reset --soft HEAD^
*This command would undo commit, but would keep changes so that we can re-modify and re-commit

Undoing GIT Merge (Not pushed yet)

With git log check which commit is one prior the merge. Then you can reset it using:

1. git log --oneline -n 2
2. git reset --hard <commit_sha_previous_to_merged_one>
git reset --hard HEAD~1

* The Content stated above is for informational purpose only. Expert Software Team is not responsible if any part of content found meaningless in any manner or condition.