2012-04-07 115 views
15

我最近做了一個git stash,然後做在樹枝上的一些工作,並試圖做一個git stash apply時提交它,並得到了這些錯誤:如何解決「刪除/修改」引發的衝突「混帳藏匿應用」

CONFLICT (delete/modify): app/controllers/orders_controller.rb deleted in Updated upstream and modified in Stashed changes. Version Stashed changes of app/controllers/orders_controller.rb left in tree. 
CONFLICT (content): Merge conflict in app/models/product.rb 

git status顯示以下內容:

$ git status 
# On branch develop 
# Your branch is ahead of 'origin/develop' by 16 commits. 
# Unmerged paths: 
# (use "git reset HEAD <file>..." to unstage) 
# (use "git add/rm <file>..." as appropriate to mark resolution) 
# 
# deleted by us:  app/controllers/orders_controller.rb 
# both modified:  app/models/product.rb 

文件標記爲「刪除/修改」是,我添加和stash之前還沒有提交新的文件。
我想回到我在git stash之前的狀態 - 沒有提交本地更改。你能建議如何做到這一點?

謝謝。

回答

8

你正在彈出隱藏到不同的狀態;狀態有一個額外的提交。如你所知,更糟的是,提交引入了合併衝突。

你有兩個選擇:

  1. 流行的是藏匿在最新提交和解決衝突
  2. 彈出藏匿到之前提交。

聽起來像#2是你想要做的。使用:

git stash branch new_branch [<stash>] # <stash> will be the last one if not provided. 
+0

謝謝。我只是意識到我做了'藏'適用於錯誤的分支。有沒有辦法在這個分支上取消「隱藏應用」? – stupakov 2012-04-07 17:19:06

+0

在「隱藏應用」之前清理了錯誤的分支嗎?而且,'是否應用'或'堆疊流行'? – GoZoner 2012-04-07 17:36:52

+0

它很乾淨,我沒有'申請' – stupakov 2012-04-07 18:04:30

0

您需要解決衝突! 由於您已經更新了最新的存儲庫,所以這兩個文件已被更改,project.rb和orders_controller.rb已在最新的存儲庫中進行了修改。同時,你的本地變更(存儲)也修改了這兩個文件,當你應用它們時,會有衝突。

您需要解決衝突才能應用您的本地更改。

對於第一個文件,orders_controller.rb 最新的回購被刪除,當您推遲以後的提交時,是否要保留它?

對於第二個文件project.rb 您需要解決文件中的衝突。