
If instead we do git reset, the result is: $ git reset HEAD - b.txt Nothing to commit, working directory clean If from this point, we do git checkout, the result is this: $ git checkout HEAD - b.txt No changes added to commit (use "git add" and/or "git commit -a") " to discard changes in working directory) I always get confused with this, so here is a reminder test case let's say we have this bash script to test git: set -xĪt this point, the change is not staged in the cache, so git status is: $ git status Note: name1, name2, nameA, subFolder - all of these example folder names indicate the folder or package where the file(s) in question may be residing. Multiple folders: git checkout - name1/name2/* nameA/subFolder/*Īgain mind the space between name1/name2/* nameA/subFolder/* in the The asterisk in the above does the trick of undoing all files at that location under name1/name2.Īnd, similarly the following can undo changes in all files for

If you happen to need to discard changes for all of the files in aĬertain directory, use the git checkout as follows: git checkout - name1/name2/* Mind the space above between name1/name2/fileOne.ext nameA/subFolder/fileTwo.ext Space as in: git checkout - name1/name2/fileOne.ext nameA/subFolder/fileTwo.ext If you have one or more files you could apply the same command ( git checkout - file ) toĮach of those files by listing each of their location separated by This answers specifically addresses question where a user has more than one file but the user doesn't want to undo all local changes: This answers is for command needed for undoing local changes which are in multiple specific files in same or multiple folders (or directories).
