Usually, to discard changes to a file you would do:
git checkout -- <file>
What if the change I want to discard is deleting the file? The above line would give an error:
error: pathspec '<file>' did not match any file(s) known to git.
What command will restore that single file without undoing other changes?
bonus point: Also, what if the change I want to discard is adding a file? I would like to know how to unstage that change as well.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…