Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa Próxima revisión Ambos lados, revisión siguiente | ||
clase:daw:daw:2eval:tema06 [2021/11/16 09:20] admin [Conflictos] |
clase:daw:daw:2eval:tema06 [2023/04/05 21:13] admin [Merge] |
||
---|---|---|---|
Línea 14: | Línea 14: | ||
{{: | {{: | ||
+ | {{: | ||
Ejemplo de Ramas | Ejemplo de Ramas | ||
Línea 50: | Línea 51: | ||
* Crear una rama nueva y subirla | * Crear una rama nueva y subirla | ||
+ | <sxh bash> | ||
git branch nuevaRama | git branch nuevaRama | ||
- | git checkout | + | git switch |
git push -u origin nuevaRama | git push -u origin nuevaRama | ||
+ | </ | ||
\\ | \\ | ||
\\ | \\ | ||
* Bajar una nueva rama | * Bajar una nueva rama | ||
+ | <sxh bash> | ||
git fetch --prune | git fetch --prune | ||
- | git checkout | + | git switch |
+ | </ | ||
<note tip> | <note tip> | ||
* '' | * '' | ||
- | * '' | + | * '' |
</ | </ | ||
Línea 71: | Línea 76: | ||
* Borrar una rama en local que ha sido mergeada o subida | * Borrar una rama en local que ha sido mergeada o subida | ||
+ | <sxh bash> | ||
git branch -d miRama | git branch -d miRama | ||
git branch --delete miRama | git branch --delete miRama | ||
+ | </ | ||
\\ | \\ | ||
Línea 79: | Línea 86: | ||
* Borrar una rama en local que NO ha sido mergeada ni subida (hay 3 formas distintas). Pero es usar el modificador '' | * Borrar una rama en local que NO ha sido mergeada ni subida (hay 3 formas distintas). Pero es usar el modificador '' | ||
+ | <sxh bash> | ||
git branch -d -f miRama | git branch -d -f miRama | ||
git branch --delete --force miRama | git branch --delete --force miRama | ||
git branch -D | git branch -D | ||
+ | </ | ||
Línea 89: | Línea 98: | ||
* Borrar una rama en remoto | * Borrar una rama en remoto | ||
+ | <sxh bash> | ||
git push origin --delete miRama | git push origin --delete miRama | ||
+ | </ | ||
\\ | \\ | ||
Línea 116: | Línea 127: | ||
- | {{:clase:daw:daw:2eval:rebase.png? | + | |
+ | '' | ||
+ | < | ||
+ | %%{init: { ' | ||
+ | gitGraph | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | </ | ||
\\ | \\ | ||
+ | '' | ||
+ | < | ||
+ | %%{init: { ' | ||
+ | gitGraph | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | '' | ||
+ | \\ | ||
+ | '' | ||
+ | < | ||
+ | %%{init: { ' | ||
+ | gitGraph | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | </ | ||
==== git merge --squash rama ==== | ==== git merge --squash rama ==== | ||
Línea 150: | Línea 204: | ||
* Bajar (o actualizar) una rama ( como master, release o develop) desde Github, | * Bajar (o actualizar) una rama ( como master, release o develop) desde Github, | ||
+ | <sxh bash> | ||
git fetch --prune | git fetch --prune | ||
- | git checkout | + | git switch |
git merge --ff-only origin/ | git merge --ff-only origin/ | ||
git fetch --prune | git fetch --prune | ||
- | git checkout | + | git switch |
git merge --ff-only origin/ | git merge --ff-only origin/ | ||
git fetch --prune | git fetch --prune | ||
- | git checkout | + | git switch |
git merge --ff-only origin/ | git merge --ff-only origin/ | ||
+ | </ | ||
\\ | \\ | ||
Línea 168: | Línea 224: | ||
* mergear , develop en release o release en master (suponiendo que están actualizadas ambas ramas porque las hemos actualizado con las órdenes anteriores) y que no hemos hecho commits directamente ni en release ni en master. | * mergear , develop en release o release en master (suponiendo que están actualizadas ambas ramas porque las hemos actualizado con las órdenes anteriores) y que no hemos hecho commits directamente ni en release ni en master. | ||
- | | + | <sxh bash> |
+ | | ||
git merge --ff-only develop | git merge --ff-only develop | ||
- | git checkout | + | git switch |
git merge --ff-only release | git merge --ff-only release | ||
+ | </ | ||
\\ | \\ | ||
Línea 180: | Línea 238: | ||
* Mergear (rebase) los cambios de origin/ | * Mergear (rebase) los cambios de origin/ | ||
+ | <sxh bash> | ||
git fetch --prune | git fetch --prune | ||
- | git checkout | + | git switch |
git rebase origin/ | git rebase origin/ | ||
+ | </ | ||
Lo normal es hacer el rebase cuando al hacer un '' | Lo normal es hacer el rebase cuando al hacer un '' | ||
Línea 201: | Línea 261: | ||
- | | + | <sxh bash> |
+ | | ||
git merge --squash lorenzo_42 | git merge --squash lorenzo_42 | ||
git commit -am " | git commit -am " | ||
+ | </ | ||
< | < | ||
Línea 213: | Línea 275: | ||
* Mergear | * Mergear | ||
- | | + | <sxh bash> |
+ | | ||
git merge develop | git merge develop | ||
+ | </ | ||
\\ | \\ | ||
\\ | \\ | ||
Línea 238: | Línea 302: | ||
Es decir que avisa que se configure para saber que hacer en caso de problemas, si con Fast-Forward, | Es decir que avisa que se configure para saber que hacer en caso de problemas, si con Fast-Forward, | ||
+ | <sxh bash> | ||
git config --global pull.ff only | git config --global pull.ff only | ||
+ | </ | ||
De esa forma podremos hacer un '' | De esa forma podremos hacer un '' | ||
Línea 309: | Línea 375: | ||
==== git rebase rama ==== | ==== git rebase rama ==== | ||
Imaginemos que queremos mergear la rama '' | Imaginemos que queremos mergear la rama '' | ||
- | |||
- | {{: | ||
Si hay un conflicto se producirá el siguiente mensaje: | Si hay un conflicto se producirá el siguiente mensaje: | ||
Línea 332: | Línea 396: | ||
Ahora debemos como antes arreglar el conflicto editando el fichero '' | Ahora debemos como antes arreglar el conflicto editando el fichero '' | ||
+ | <sxh bash> | ||
git add index.html | git add index.html | ||
git rebase --continue | git rebase --continue | ||
+ | </ | ||
| | ||
Es decir añadir el fichero que ha dado el conflicto con un '' | Es decir añadir el fichero que ha dado el conflicto con un '' | ||
Línea 340: | Línea 406: | ||
<sxh bash> | <sxh bash> | ||
- | git checkout | + | git switch |
git rebase origin/ | git rebase origin/ | ||
- | vi index.html | + | vi index.html |
git add index.html | git add index.html | ||
git rebase --continue | git rebase --continue | ||
Línea 352: | Línea 418: | ||
Imaginemos que queremos mergear una rama de una funcionalidad llamada " | Imaginemos que queremos mergear una rama de una funcionalidad llamada " | ||
- | {{: | + | |
- | + | ||
Si hay un conflicto se producirá el siguiente mensaje: | Si hay un conflicto se producirá el siguiente mensaje: | ||
Línea 363: | Línea 428: | ||
Ahora debemos como antes arreglar el conflicto editando el fichero '' | Ahora debemos como antes arreglar el conflicto editando el fichero '' | ||
+ | <sxh bash> | ||
git commit -am " | git commit -am " | ||
+ | </ | ||
| | ||
Línea 369: | Línea 436: | ||
<sxh bash> | <sxh bash> | ||
- | git checkout | + | git switch |
git merge --squash Lorenzo_3 | git merge --squash Lorenzo_3 | ||
vi index.html | vi index.html | ||
Línea 385: | Línea 452: | ||
Imaginemos que queremos mergear los cambios de '' | Imaginemos que queremos mergear los cambios de '' | ||
- | {{: | ||
Si hay un conflicto se producirá el siguiente mensaje: | Si hay un conflicto se producirá el siguiente mensaje: | ||
Línea 395: | Línea 461: | ||
</ | </ | ||
- | Ahora debemos como antes arreglar el conflicto editando el fichero '' | + | Ahora debemos como antes arreglar el conflicto editando el fichero '' |
+ | |||
+ | <sxh bash> | ||
+ | git add index.html | ||
git merge --continue | git merge --continue | ||
+ | </ | ||
+ | | ||
+ | Es decir añadir el fichero que ha dado el conflicto con un '' | ||
+ | |||
Línea 403: | Línea 476: | ||
<sxh bash> | <sxh bash> | ||
- | git checkout | + | git switch |
git merge develop | git merge develop | ||
vi index.html | vi index.html | ||
+ | git add index.html | ||
git merge --continue | git merge --continue | ||
</ | </ | ||
\\ | \\ | ||
- | ===== Mas cosas de Git ===== | + | ===== Stash ===== |
- | Para acabar dejamos alguna pincelada mas de cosas que existen en Git pero que no vamos a ver: | + | Hay veces que queremos guardar temporalmente los cambios para despues volver |
- | * fixup y autosquash: https:// | + | git contiene una orden para hacer eso: |
- | < | + | < |
- | git commit --fixup <commit> | + | git stash |
- | git rebase -i --autosquash | + | |
</ | </ | ||
- | |||
- | * Stash | + | Y si luego queremos recuperar los cambios se hace con: |
- | < | + | < |
- | git stash | + | |
git stash pop | git stash pop | ||
</ | </ | ||
- | * Cherry-pick | + | ===== Recetas |
- | + | ||
- | + | ||
- | ==== Recetas ==== | + | |
* Bajarse lo último de las 3 ramas. | * Bajarse lo último de las 3 ramas. | ||
- | < | + | < |
- | git fetch --prune && git checkout | + | git fetch --prune && git switch |
</ | </ | ||
* Hacer un merge de las 3 ramas | * Hacer un merge de las 3 ramas | ||
- | < | + | < |
- | git checkout | + | git switch |
</ | </ | ||
* Subir las 3 ramas | * Subir las 3 ramas | ||
- | < | + | < |
- | git checkout | + | git switch |
</ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||