19 views

OK, you made some local changes and changed your mind. You wanted to ignore all local changes and revert all files back to the last commit state. Git provides an option to do this quickly using git reset --hard

git reset --hard

WARNING: This will permanently revert the local changes, there is no way to recover these changes back.

Example Step1: List out all local changes using git status

[developer@askdevops repo]$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   public_html/.htaccess
#       modified:   public_html/qa-theme/Donut-theme/css/donut.css
#
no changes added to commit (use "git add" and/or "git commit -a")

Example Step2: Reset local changes to the last commit

[developer@askdevops repo]$ git reset --hard
HEAD is now at ababa123 release-v102

Example Step3: check git status again

[developer@askdevops repo]$ git status
# On branch master
nothing to commit, working directory clean
[developer@askdevops repo]$
Oct 16, 2018 by | 19 views
DevOpsRun.com is LIVE!

Articles for DevOps Geeks
MobaXterm Customization
CHMOD Explained!
Bash history powerful tips
Ubuntu bash from Windows
..