To discard uncommitted changes in Git, you can use a specific command in your terminal. This process reverts any modifications made to tracked files that have not been staged or committed. To do this, simply open your terminal and execute the following command:

git checkout -- <filename>

Replace <filename> with the name of the file you want to revert. If you wish to discard changes in all modified files, you can also use:

git checkout .

Please note that this action is irreversible, and any uncommitted changes will be permanently lost. Always ensure that you do not need your changes before running this command.

Tagged in: