There are times that we have some code in our working
directory that we want to throw away. Let's say we made some
changes, but we didn't like those changes. So we want to
scratch everything and start over, we can discard the local
changes using the Restore command. So here we have some
local changes in file one dot j, s. To undo this changes, we type
Git restore, file one dot j s, when we execute this command,
Git is going to take the version of this file in the next
environment, which is our staging environment, it's going
to take that version and copy into our working directory. We
can also use a period here, and this will undo all the local
changes. Now let me show you something. So the command is
executed. Now let's run another short status. But file two is
still here. Why is that? Well, this is a new untracked file. So
Git hasn't been tracking this. So when we tell Git to reassert
this file, git doesn't know where to get a previous version
of his file. It doesn't exist in our staging environment or In
our repository, so, to remove all these new untracked files,
we have to type git clean. Take a look. By default, we get this
fatal error saying required for us to false to true. And neither
of these searches are given. So basically git us telling us that
hey, this is a dangerous operation. If you accidentally
remove this on track files, there is no way you can recover
them. So let's try and git clean dash H for a quick help. Here we
have this option dash F, which forces git to remove this on
track fast. You also have dash D for removing whole directories.
So quite often we type Git clean dash fd. Now, let's run short
status again. File two is gone. So this is how we undo local
changes.