0

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

  • 2
    Does 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 Answers1

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