git 如何恢复上次提交的文件

蒂娜

提交一些文件后,将更改本地文件。现在,我想将本地目录恢复到与上次提交完全相同的目录。下图中,local uncommitted changes被破坏了,所以想把master基本算子拿出来....我已经试过了git reset [the first commit hash code from git log],但是没有任何变化.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

在此处输入图片说明

bu

git reset <commit>更改HEAD指向的位置,但不会将文件还原为该提交时的状态。如果要将文件还原为提交时的外观,则需要git reset --hard <commit>

关于三种重置模式:

       --soft
           Does not touch the index file or the working tree at all (but
           resets the head to <commit>, just like all modes do). This
           leaves all your changed files "Changes to be committed", as git
           status would put it.

       --mixed
           Resets the index but not the working tree (i.e., the changed
           files are preserved but not marked for commit) and reports what
           has not been updated. This is the default action.

           If -N is specified, removed paths are marked as intent-to-add
           (see git-add(1)).

       --hard
           Resets the index and working tree. Any changes to tracked files
           in the working tree since <commit> are discarded.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章