I made a branch and made some local changes but I ended up messing up some of the project itself. How do I revert these local changes that weren't staged and did not commit. I'd want to get back to how old the project was originally without affecting any other branches or main
Asked
Active
Viewed 357 times
0
-
2Does this answer your question? [git undo all uncommitted or unsaved changes](https://stackoverflow.com/questions/14075581/git-undo-all-uncommitted-or-unsaved-changes) – SwissCodeMen Nov 27 '21 at 21:49
1 Answers
1
You can use git checkout path/to/the/file/with/local/changes
to discard all changes in that particular file. If you want to discard all local changes that are not committed, you can use .
as the path when running the command from the repository root directory: git checkout .
.
If you want to selectively discard only some parts of the local changes, you can use the interactive git checkout --patch
command, which will walk you through the local changes you have made, and lets you choose whether you want to discard them or not.

Frost
- 11,121
- 3
- 37
- 44
-
To create clarity: `git checkout .` must execute in root repo to discard *all* local changes – SwissCodeMen Nov 27 '21 at 21:50
-