1

我一直在本地存储库上编辑和创建文件,当我发出 git status 命令时,我看到以下内容。

# On branch master
# 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)
#
#   modified:   app/database/migrations/2013_06_06_111226_update_users_table.php
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   app/database/migrations/2013_06_12_092117_create_private_message_tables.php
no changes added to commit (use "git add" and/or "git commit -a")

我在其中一个文件中犯了一个错误,现在我想重新开始。

我如何回到我进行更改并添加到列出的文件之前?

4

1 回答 1

4

对于未跟踪的文件,如果您不再需要它,只需将其删除。对于高级/大规模清理,请查看git clean. 对于修改后的文件,只需执行以下操作:

git checkout app/database/migrations/2013_06_06_111226_update_users_table.php

它将回到您上次提交的干净副本。

于 2013-06-12T16:04:25.490 回答