2011-06-22 24 views
25

ブランチをマージするときに、競合するファイルが10個あります。私は10ファイルのすべての競合を解決しました(長い時間がかかりました)。残念なことに、コミットの前に、私は1つのファイルが間違ってマージされていることを知り、このファイルを再び開始する必要があります。 :(1つのファイルということを再マージする方法、他の言葉では、マージされていないマージされたファイルをマークする方法Gitリポジトリ内gitでファイルを再マージするには?

、?

+0

が重複する可能性[1つだけのファイルのマージをやり直し](のhttp://のstackoverflow。 com/questions/6857082 /シングルファイルのやり直し) –

答えて

29
git checkout -m <filename> 

これはインデックスから削除されますと、その後、マージを行うために必要なすべてのマーカーを持っている「競合」ファイルに戻すgitのヘルプチェックアウトのmanページから

:。

-m, --merge 
    When switching branches, if you have local modifications to one or more files that are different between the current branch and the branch to which you are switching, the command refuses to switch 
    branches in order to preserve your modifications in context. However, with this option, a three-way merge between the current branch, your working tree contents, and the new branch is done, and you 
    will be on the new branch. 

    When a merge conflict happens, the index entries for conflicting paths are left unmerged, and you need to resolve the conflicts and mark the resolved paths with git add (or git rm if the merge should 
    result in deletion of the path). 

    When checking out paths from the index, this option lets you recreate the conflicted merge in the specified paths. 

(最後の文は、最も重要なものですが) 。ここで

は、それが追加された理由を説明し、それはgitのの古いバージョンでは不可能であるどのようにブログの記事です:のhttp://gitster.livejournal.com/43665.html

+0

ありがとう、それは動作します:) – Nyambaa

+0

+1 Sweet!その最後のことを-mと知りませんでした。確かに非常に便利! – ralphtheninja

+0

@Magnus Skog:私はそれを1回か2回使ったので、再びそれを見つけるためにマニュアルページを掘り下げなければなりませんでした。 –

関連する問題