git撤销操作
Swift

git有如下三种状态:

  • Modified: You have changed the file but have not committed it to your database yet.
  • Staged: You have marked a modified file in its current version to go into your next commit snapshot.
  • Committed: The data is safely stored in your local database.

现在主要讲述下git的撤销操作:

discard changes in working directory

前提:<file>已经被添加到暂存区

1
git restore <file>

working direction <- index

1
git reset HEAD <file>

index <- HEAD

1
git reset --soft HEAD^

working direction <- HEAD

1
git reset --hard HEAD^