Forrest logo
back to the git tool

git-checkout:tldr:3673d

git-checkout: Discard all unstaged changes in the current directory (see `git reset` for more undo-like commands).
$ git checkout .
try on your machine

The command "git checkout ." is used to discard changes made to the files in your working directory and revert them back to the state they had in the last commit.

Specifically, this command can be broken down as follows:

  • "git checkout" is the command used in Git to switch between different branches or to restore files from a previous commit.
  • The dot (.) after "git checkout" represents the current directory or working directory.
  • When you add the dot (.), it instructs Git to perform the checkout operation on all files in the working directory.

Therefore, "git checkout ." discards any changes made to the files in your current working directory and brings them back to the state they were in the last commit.

It's important to note that this operation cannot be undone, so you should be cautious when using it. If you want to keep the changes you made in some files and discard changes only in specific files, you can individually specify those files instead of using the dot. For example, "git checkout file.txt" would discard changes only in the specific file named "file.txt".

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the git tool