2016-08-01 128 views
-1

昨天我做了git pull,它从Github回购中获取最新副本。Git - 撤消所有更改更改

我昨天做了一些编码,但我没有做git add .

现在我想重置它是什么,从昨天 - 这意味着除去从昨天回来的一切工作变为原来的(最后的git拉)。

如何做到这一点?

$ git status 
On branch develop 
Your branch is behind 'origin/develop' by 5 commits, and can be fast-forwarded. 
    (use "git pull" to update your local branch) 
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/Http/Kernel.php 
     modified: app/Http/routes.php 
     modified: composer.json 
     modified: database/seeds/DatabaseSeeder.php 

no changes added to commit (use "git add" and/or "git commit -a") 
+1

的可能的复制[如何恢复未提交的更改,包括文件和文件夹?(http://stackoverflow.com/questions/5807137/how-to-revert-uncommitted-changes-including -files-and-folders) –

回答

2

如果没有git add,因此没有git commit,只想状态看起来像昨天,一个简单的硬重置将修复它。

git reset --hard 
+0

谢谢。如果git add的未来确实发生,那么解决方案是什么? –

+1

你为什么不试试看看?你有什么损失呢?答:只有你想失去的东西。尝试它会比提出这样的基本问题更快,这些问题很早就在任何一半的“git”教程中提及。而通过尝试它,你会发现这两种方式都没有区别。 –

+1

@I'll-Be-Back,如果你添加并且没有提交,那么同样的解决方案就可以工作。如果你添加并提交,那么你需要'git reset --hard origin/master'。 – merlin2011