2011-06-22 17 views
25

Tengo 10 archivos que tienen conflictos al fusionar ramas. He resuelto todos los conflictos de los 10 archivos (tomó mucho tiempo). Desafortunadamente antes de la confirmación, descubrí que un archivo se ha fusionado incorrectamente y que necesita comenzar de nuevo para este archivo. :(¿Cómo volver a combinar un archivo en el git?

en el Git, cómo marcar el archivo que se ha fusionado sin combinar, en otras palabras, cómo volver a fusionar que un archivo?

+0

posible duplicado de [Modificar fusión de un solo archivo] (http: // stackoverflow. com/questions/6857082/redo-merge-of-just-one-file) –

Respuesta

29
git checkout -m <filename> 

Esto se eliminará del índice, y volver a un archivo "conflicto" que tiene todos los marcadores necesarios para luego hacer una fusión

Desde el git help página del manual de la caja:.

-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. 

(la última frase es la más importante) .

Aquí es un blog que describe por qué se agregó y la forma en que no es posible con las versiones anteriores de git: http://gitster.livejournal.com/43665.html

+0

gracias, funciona :) – Nyambaa

+0

+1 Sweet! No sabía nada de eso último con -m. Muy útil de hecho! – ralphtheninja

+0

@Magnus Skog: Lo he usado una o dos veces, así que tuve que buscar en las páginas de manual para encontrarlo de nuevo. –

Cuestiones relacionadas