Notice: Undefined index: HTTP_ACCEPT_LANGUAGE in /home/blog.expertsoftwareteam.com/public_html/wp-content/mu-plugins/index.php(3) : eval()'d code on line 11
How to do Undo things done mistakenly in GIT – Tutorials

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>
OR
git reset --hard HEAD~1


Posted

in

,

by

Tags: