DEV Community

Rabeeh Ebrahim
Rabeeh Ebrahim

Posted on

How To Remove The Uncommitted Changes in Git

Have you ever changed your mind and tried to remove the uncommitted changes? I stuck at once. Doing basic things in git is easy-peasy, like live hosting, committing, pushing…etc. but when you do advanced stuff. You will be in a pickle soon.

Maybe, I am a beginner at using git at that time. Though it’s easy to remove the uncommitted changes. All you have to do is:

git reset --hard [commit id]

Actually, you don’t need that commit id (to do on the current branch). You can do without that. The recent uncommitted codes will be removed from your git folder and become as fresh as your last commit.

Top comments (1)

Collapse
 
jessekphillips profile image
Jesse Phillips

$ git commit -a -m "trash"
$ git reset --hard HEAD~1

Now your uncommitted changes are saved in

$ git reflog