DEV Community

AquaCat
AquaCat

Posted on

2

【Github】How to restore the status of the file in your working directory

You are coding and you hit the command "git add ." and "commit -m XXX (comment) ." Then, you noticed some files that you believe that you have not changed on the ""modified files" list. Do not panic.

1.Hit "git reset --soft HEAD^" to cancel the commit.
2.Hit "git restore --staged " to unstage the file.
3.Hit "git diff -- " to check what has been changed in these files are really changed.
4.If you think that those changes would not be a problem, hit "git checkout " to restore the status of the file (restore the status before the commit was executed.)
This is like a "transaction." If you hit "git checkout ," those changes that were added to the file will not be
restored ,ever again. Make sure there would be no problem after you execute "git checkout."

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay