2015-09-20 76 views
0

我做了一個倒車導致補丁一個Git藏匿失敗

git stash 

然後

git rebase origin/master 

這都是成功的。

然而

git stash apply 

沒有這麼開心:

$git stash apply 
Auto-merging yarn/pom.xml 
CONFLICT (content): Merge conflict in yarn/pom.xml 
Auto-merging unsafe/pom.xml 
CONFLICT (content): Merge conflict in unsafe/pom.xml 
Auto-merging tools/pom.xml 
CONFLICT (content): Merge conflict in tools/pom.xml 
Auto-merging streaming/pom.xml 
CONFLICT (content): Merge conflict in streaming/pom.xml 
Auto-merging sql/hive/pom.xml 
CONFLICT (content): Merge conflict in sql/hive/pom.xml 
Auto-merging sql/hive-thriftserver/pom.xml 
CONFLICT (content): Merge conflict in sql/hive-thriftserver/pom.xml 
.. 

這似乎是恢復了apply是一個共識的方法:

$git stash show -p | git apply -R 

但是導致:

error: patch failed: assembly/pom.xml:20 
error: assembly/pom.xml: patch does not apply 
error: patch failed: bagel/pom.xml:20 
error: bagel/pom.xml: patch does not apply 
error: patch failed: core/pom.xml:20 
error: core/pom.xml: patch does not apply 
error: patch failed: examples/pom.xml:20 
error: examples/pom.xml: patch does not apply 
error: patch failed: external/flume-assembly/pom.xml:20 
.. and so on .. 

那麼有沒有辦法將整個stash apply回滾?

回答

0

由於與應用隱藏更改相同的原因,您恢復隱藏更改失敗:底層內容已更改太多,所以該補丁不太適合。

如果你只是想將所有文件恢復爲HEAD的內容,所有你需要的是:

git reset --hard 

從手冊:

git reset [<mode>] [<commit>] 
     This form resets the current branch head to <commit> and possibly 
     updates the index (resetting it to the tree of <commit>) and the 
     working tree depending on <mode>. If <mode> is omitted, defaults to 
     "--mixed". The <mode> must be one of the following: 

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

是的,知道的git復位(又做了些什麼作爲一個解決方法)..但想更好地理解什麼是不正確的/破壞在git存儲還原。 – javadba

+0

您在應用隱藏的更改時遇到的問題相同:底層內容已更改太多,因此該補丁不太適合。 –

+0

其實你的評論對你答案的用處很重要。建議你更新你的答案。 – javadba