git checkout --<pathname>

Discard changes in working directory.

This command reverts any changes made to the specified file(s) in the working directory, returning them to their state from the last commit.

It achieves its goal by copying the content of the current branch's latest commit into your working directory, overwriting local changes.

Potential variations include using git checkout <branch_name> to switch branches or git checkout <commit_hash> -- <pathname> to revert to a specific commit's state for a file.

Sign in to enable bookmarking, reminders, progress-tracking and more...