Skip to content

Instantly share code, notes, and snippets.

@pablomp
Last active December 22, 2015 10:59
Show Gist options
  • Save pablomp/6462780 to your computer and use it in GitHub Desktop.
Save pablomp/6462780 to your computer and use it in GitHub Desktop.
GIT deploy sobreescribiendo la rama
Hacer un deploy en GIT sustituyendo los fuentes locales con la copia operativa del repositorio en origin.
Tendremos en cuenta los submódulos nuevos y los existentes.
1- Descargamos lo que hay en el repositorio, incluyendo los submódulos existentes
git fetch --all --depth=1
2- Inicializamos los nuevos submódulos
git submodule init
3- Descargamos los nuevos submódulos
git submodule update
4- Sustituimos el branch local con el que tenemos en origin(master)
git reset --hard origin/master
5- Sustituimos en branch local con el que tenemos en origin(master), en los submódulos
git submodule foreach git reset --hard origin/master
6- Eliminar los ficheros y directorios que no estén trackeados por GIT
git clean -f -d
Código completo:
git fetch -q --all --depth=1
git submodule -q init
git submodule -q update
git reset -q --hard origin/master
git submodule foreach git reset -q --hard origin/master
git clean -q -f -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment