As the genisage noted in the comment , you ask git to explicitly check outside the databaseName.tmp file, as if you entered:
git checkout -- databaseName.tmp
This is because the entered * processed by the shell before git can see your command. The shell replaces * all the file names in your current working directory, 1 and then doing this, then running git , without any indication that the actual command entered had * in it, and not in all of these names.
Again, git does not know that you used the asterisk * character, all it sees is a list of file names, including any files with an ignored top level that are not stored in git.
It is vague if you manage somehow 2 to pass the letter asterisk * to git, git will expand * , but with a different set of file names: those known as git. This will do what you want.
There is an easier way: git will recursively check directories, checking all the files that it knows about in that directory. So instead of * just use . to ask git to check the current directory:
git checkout -- .
If git knows about ./a and ./b but not ./databaseName.tmp , it will check ./a and ./b and not try to do anything with ./databaseName.tmp . 3
1 More precisely, files whose names do not begin with a leading point . .
2 And itβs actually quite easy to control, for example, just insert a backslash \ in front of the asterisk: git checkout -- \* . Or, use single or double quotes, both of which protect against shell pushing. Single quotes also prevent expansion of a shell variable, while double quotes allow expansion of a variable, but prevent globalization.
3 It is worth noting a slight difference here: * expands to file names that do not start with . while the git request for validation . forces it to check all files in the directory, including those whose names begin with . . Therefore, both git checkout -- \* and git checkout -- * , for example, will not .secret changes to a file named .secret , and git checkout -- . discard such changes.