git un-remove before commit?
Solution 1:
To get the version from the current commit (HEAD
) into both the index (staging area, what you're about to commit) and the work tree:
git checkout HEAD filename.txt
Note that this isn't just for "unremoval" - it's for getting you back to the version from the commit, whether you've modified it by changing one line or deleting the entire file.
Also, in case others find this looking for a slightly different answer, if you want to get the version from the index back into the work tree, you can use
git checkout filename.txt
That's handy for when you manage to stage everything for a commit, then do something stupid (like remove a file) - you can save yourself by recovering from the index.