2012-07-31 14 views
12

Me acabo de encontrar la herramienta git-sub-árbol que hace algún tiempo se convirtió en una parte del repositorio git principal https://github.com/apenwarr/git-subtree/¿Cuál es la diferencia entre el sub-árbol git merge y git-subárbol

Sin embargo no entiendo completamente lo que la funcionalidad proporciona esta herramienta sobre el "árbol de lectura de git" ya existente "subárbol de fusión de git" ya existente. ¿Es el único propósito de git-subárbol, hacer que el historial de confirmaciones resultante se vea mejor o tiene más funcionalidades que he pasado por alto?

Respuesta

12

Los comandos que describe leen un subárbol en un repositorio. El comando git-subtree tiene muchas más opciones, como se describe por the documentation. Entre otros, se puede (anotados por simplicidad):

add:: 
    Create the <prefix> subtree by importing its contents 
    from the given <refspec> or <repository> and remote <refspec>. 
merge:: 
    Merge recent changes up to <commit> into the <prefix> 
    subtree. 
pull:: 
    Exactly like 'merge', but parallels 'git pull' in that 
    it fetches the given commit from the specified remote 
    repository. 
push:: 
    Does a 'split' (see above) using the <prefix> supplied 
    and then does a 'git push' to push the result to the 
    repository and refspec. This can be used to push your 
    subtree to different branches of the remote repository. 
split:: 
    Extract a new, synthetic project history from the 
    history of the <prefix> subtree. The new history 
    includes only the commits (including merges) that 
    affected <prefix>, and each of those commits now has the 
    contents of <prefix> at the root of the project instead 
    of in a subdirectory. Thus, the newly created history 
    is suitable for export as a separate git repository. 

También hay una variedad de banderas que ayudan y manipular los anteriores. Creo que todas estas opciones estaban disponibles antes a través de cadenas de comandos de plomería. git-subtree.sh simplemente los envuelve y los hace considerablemente más fáciles de ejecutar.

5

Si nos fijamos en el código sub-árbol viejo antes de que se añadió a git como un módulo contrib: https://github.com/apenwarr/git-subtree/blob/master/git-subtree.sh se puede ver que la herramienta git subárbol es realmente un envoltorio más avanzada en todo el subárbol nivel inferior git fusión de estrategias.

Básicamente aprovecha esas estrategias de una manera sensata para hacer la gestión del subárbol mucho más fácil. En particular, las cosas de la mierda son realmente útiles.

Cuestiones relacionadas