2013-06-12 19 views
1

我一直在編輯和創建我的本地回購文件,當我發出git status命令時,我看到以下內容。Git - 回滾到之前的變化

# 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") 

我犯了一個錯誤的文件,現在我想重新開始。

我如何回到之前我做了更改並添加到列出的文件?

+2

僅供參考:狀態信息告訴你如果你想擺脫變化,你應該怎麼做。 '(使用「git checkout - ...」放棄工作目錄中的更改)' – Schleis

回答

4

對於未跟蹤的文件,只需刪除它,如果你不想要它了。要進行高級/大規模清理,請參閱git clean。對於修改後的文件,只需執行以下操作:

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

然後它將返回到上次提交的乾淨副本。

+0

謝謝,這就是我正在尋找 – BigJobbies