
Nothing to commit, working tree clean Unstage commit on Git $ git checkout - READMEĪlternatively, if you want to discard your entire working directory, head back to the root of your project and execute the following command. In order to discard changes done to this unstaged file, execute the “git checkout” command and specify the filename. No changes added to commit (use "git add" and/or "git commit -a") " to discard changes in working directory) $ git checkout - Īgain, let’s say that you have one file that is currently unstaged in your working directory. In order to remove unstaged changes, use the “ git checkout ” command and specify the paths to be removed. In some cases, after unstaging files from your staging area, you may want to remove them completely. Nothing added to commit but untracked files present (use "git add" to track) Remove unstaged changes on Git In order to unstage all files and directories, execute “git reset” and they will be removed from the staging area back to your working directory. $ git resetĪgain, let’s pretend that you have created two files and one directory and that you added them to your staging area. To unstage all files, use the “git reset” command without specifying any files or paths. In some cases, you may want to unstage all your files from your index. Previously, we have seen how you can unstage a file by specifying a path or a file to be reset. Nothing added to commit but untracked files present (use "git add" to track)Īs you probably understood it by now, the “ git reset” command is doing the exact opposite of the “ git add” command : it removes files from the index. You can now check the status of your working directory again with “git status” $ git status In order to unstage the README file, you would execute the following command $ git reset - README Your branch is up to date with 'origin/master'.

This command will reset the index entries (the ones you added to your staging area) to their state at the specified commit (or HEAD if you didn’t specify any commits).Īlso, we use the double dashes as argument disambiguation meaning that the argument that you are specifying may be related to two distinct objects : branches and directories for example.Īs a quick example, let’s pretend that you added a file named “README” to your staging area, but now you want to unstage this file. git reset - īy default, the commit parameter is optional : if you don’t specify it, it will be referring to HEAD. The easiest way to unstage files on Git is to use the “ git reset ” command and specify the file you want to unstage.
