Inicio·Comandos de terminal
Publicidad

Consigue tu bono en un exchange de criptomonedas

Bonos que recibes solo por registrarte. Las condiciones son las que publica cada exchange.

git submodule

git

Uso

git submodule update --init --recursive

Fija otro repositorio en un commit dentro del tuyo; un clon normal deja la carpeta vacía hasta update --init, y el padre apunta a un commit, no a una rama.

Opciones habituales

OpciónSignificado
add <url> <path>pin another repository at a path
update --initfill in a submodule folder that a clone left empty
--recursivego into submodules of submodules
update --remotemove the pin to the tip of the tracked branch
statusthe commit each submodule sits at
deinit <path>unregister it
foreach <cmd>run a command in each one

Ejemplos

git submodule update --init --recursive

the command that fills empty submodule folders after a clone

git submodule add https://github.com/x/lib.git vendor/lib

adds a dependency as a submodule

git submodule update --remote

updates the pinned commit to the branch tip

Lo confuso es que deshacer tiene varias formas: mover a dónde apunta una rama no es lo mismo que añadir un commit que la revierte.

Cómo leerlo

  • Los corchetes [ ] marcan una parte que puedes omitir.
  • Los puntos suspensivos … indican que puedes poner varios.
  • Las opciones distinguen mayúsculas: en algunos comandos -r y -R no hacen lo mismo.

Preguntas

Q¿Qué hace git submodule?

Fija otro repositorio en un commit dentro del tuyo; un clon normal deja la carpeta vacía hasta update --init, y el padre apunta a un commit, no a una rama.

Q¿Cómo se escribe?

git submodule update --init --recursive — los corchetes marcan lo que puedes omitir.

Q¿Cuántas opciones vale la pena saber?

Aquí van 7; la lista completa está en man git. Este comando está en git.

Comandos relacionados

página man: man git-submodule