I am a beginner in git.
What I've learned so far is that if I use git checkout -- <file>
the file will be checked out from the staging area, if the file was staged, and from the last commit if the file was not staged.
Now, if the file was staged after modification, and I try to replace the file in the working tree with the last committed version using git checkout HEAD -- <file>
, it also removes the file from the staging area.
Is it possible to keep the initial modifications in the staging area and get the last committed version of the file in the working tree?