【发布时间】:2015-06-05 19:43:02
【问题描述】:
我有一个文件“a.txt”
git add a.txt
现在,我删除 a.txt(或修改它)。
那我想要那个我已经添加到暂存区的.txt
我该怎么做?
【问题讨论】:
我有一个文件“a.txt”
git add a.txt
现在,我删除 a.txt(或修改它)。
那我想要那个我已经添加到暂存区的.txt
我该怎么做?
【问题讨论】:
git status 的输出包含您要查找的信息:
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
因此,在这种情况下,您应该运行:
git checkout -- a.txt
【讨论】:
git checkout -- a.txt 从暂存区获取它,git checkout HEAD a.txt 从存储库获取它