How to revert git uncommitted changes including files and folders
First read two of my new posts in this regard:
You can list the files that will be reverted without actually making any action, just to check what will happen, with:
git checkout --
Then if you want to undo / revert the changes only in current working directory, use
git checkout -- .
Maybe you wan to know how
git reset --hard
works? It will undo both staged and unstaged changes, whereas ‘git checkout — .’ will undo only unstaged changes.
Attention:
git reset --hard
will revert changes to modified files. and the following command will remove all untracked files and directories. (`-f` is `force`, `-d` is `remove directories`)
git clean -fd
It is good idea to run
git clean -nd
to preview the changes before running git clean to ensure you don’t have untracked files or directories that you care about that will be removed. -n is dry run which shows output without doing anything yet.
Just think about a scenario:
You have committed a git, then you want to undo it. In addition, you have some modifications that you don’t want them. So there is two tasks.
for undoing the last commit, you can use this tutorial:
https://panjeh.medium.com/remove-last-commit-local-undo-the-most-recent-commit-git-github-repository-e8d4701f006e
but don’t forget you have also some modifications that you don’t need them so you can use
git clean -nd
git clean -fd
I would like to introduce two packages for Laravel that I have recently developed: Laravel Pay Pocket, a modern multi-wallet package, and Laravel Failed Jobs, a UI for the Laravel Failed Jobs Table. I hope they may be of help to you.
https://github.com/HPWebdeveloper/laravel-pay-pocket
https://github.com/HPWebdeveloper/laravel-failed-jobs