Herramientas de usuario

Herramientas del sitio


clase:daw:daw:2eval:tema06

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
clase:daw:daw:2eval:tema06 [2021/11/16 20:19]
admin [Recetas]
clase:daw:daw:2eval:tema06 [2024/01/02 10:07] (actual)
admin [Usando Ramas]
Línea 14: Línea 14:
 {{:clase:daw:daw:1eval:git-flow.png?600|}} {{:clase:daw:daw:1eval:git-flow.png?600|}}
  
 +{{:clase:daw:daw:2eval:drinkinggame.jpg|}}
  
 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 nuevaRama +  git switch nuevaRama 
-  git push -u origin nuevaRama+  git push --set-upstream origin nuevaRama 
 +  git push -u             origin nuevaRama
  
 +</sxh>
 \\ \\
 \\ \\
   * Bajar una nueva rama   * Bajar una nueva rama
  
 +<sxh bash>
   git fetch --prune      git fetch --prune   
-  git checkout nuevaRama+  git switch nuevaRama
  
 +</sxh>
 <note tip> <note tip>
   * ''fetch'':Se pone ''--prune'' , para que borre las referencias locales de ramas remotas que ya no están.   * ''fetch'':Se pone ''--prune'' , para que borre las referencias locales de ramas remotas que ya no están.
-  * ''checkout'': Por defecto al cambiar a la nueva rama ya se hace un ''--track'' a ''origin/nuevaRama''+  * ''switch'': Por defecto al cambiar a la nueva rama ya se hace un ''--track'' a ''origin/nuevaRama''
 </note> </note>
  
Línea 71: Línea 77:
   * 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
 +</sxh>
  
 \\ \\
Línea 79: Línea 87:
   * Borrar una rama en local que NO ha sido mergeada ni subida (hay 3 formas distintas). Pero es usar el modificador ''-f'' o ''--force''   * Borrar una rama en local que NO ha sido mergeada ni subida (hay 3 formas distintas). Pero es usar el modificador ''-f'' o ''--force''
  
 +<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         miRama   git branch -D         miRama
 +</sxh>
  
  
Línea 89: Línea 99:
   * Borrar una rama en remoto   * Borrar una rama en remoto
  
 +<sxh bash>
   git push origin --delete miRama   git push origin --delete miRama
 +</sxh>
  
 \\ \\
Línea 114: Línea 126:
  
 Se usa para poner los commits de  origin/develop en nuestra develop de antes que lo de develop porque hay commits distintos en cada rama pero del mismo commit origen Se usa para poner los commits de  origin/develop en nuestra develop de antes que lo de develop porque hay commits distintos en cada rama pero del mismo commit origen
- 
  
 {{:clase:daw:daw:2eval:rebase.png?direct|}} {{:clase:daw:daw:2eval:rebase.png?direct|}}
 +
 +
 +''git commit -m "E"''
 +<flow>
 +%%{init: { 'logLevel': 'debug', 'theme': 'default','themeVariables': {  'git0': '#6D97CA','git1': '#00ffff' }, 'gitGraph': {'showBranches': true, 'showCommitLabel':true,'mainBranchName': 'origin/develop','rotateCommitLabel': false}} }%%
 +gitGraph
 + commit id: "A"
 + commit id: "B"
 + branch develop
 + commit id: "E"
 +
 +
 +</flow>
  
 \\ \\
 +''git fetch --prune''
 +<flow>
 +%%{init: { 'logLevel': 'debug', 'theme': 'default','themeVariables': {  'git0': '#6D97CA','git1': '#00ffff' }, 'gitGraph': {'showBranches': true, 'showCommitLabel':true,'mainBranchName': 'origin/develop','rotateCommitLabel': false}} }%%
 +gitGraph
 + commit id: "A"
 + commit id: "B"
 + branch develop
 + commit id: "E"
 + checkout origin/develop
 + commit id: "C"
 + commit id: "D"
 +
 +
 +</flow>
 +
 +\\
 +'' git switch develop''
 +\\
 +''git rebase origin/develop''
 +<flow>
 +%%{init: { 'logLevel': 'debug', 'theme': 'default','themeVariables': {  'git0': '#6D97CA','git1': '#00ffff' }, 'gitGraph': {'showBranches': true, 'showCommitLabel':true,'mainBranchName': 'origin/develop','rotateCommitLabel': false}} }%%
 +gitGraph
 + commit id: "A"
 + commit id: "B"
 + commit id: "C"
 + commit id: "D"
 + branch develop
 + commit id: "E"
 + checkout origin/develop
 +
 +
 +</flow>
  
 ==== git merge --squash rama ==== ==== git merge --squash rama ====
Línea 137: Línea 193:
  
 \\ \\
 +
 +<flow>
 +%%{init: { 'logLevel': 'debug', 'theme': 'default','themeVariables': {  'git0': '#6D97CA','git1': '#00ffff' }, 'gitGraph': {'showBranches': true, 'showCommitLabel':true,'mainBranchName': 'develop','rotateCommitLabel': false}} }%%
 +gitGraph
 + commit id: "A"
 + commit id: "B"
 + commit id: "C"
 + commit id: "D"
 +</flow>
 +
 +\\
 +''git fetch --prune''
 +<flow>
 +%%{init: { 'logLevel': 'debug', 'theme': 'default','themeVariables': {  'git0': '#6D97CA','git1': '#00ffff' }, 'gitGraph': {'showBranches': true, 'showCommitLabel':true,'mainBranchName': 'develop','rotateCommitLabel': false}} }%%
 +gitGraph
 + commit id: "A"
 + commit id: "B"
 + commit id: "C"
 + commit id: "D"
 + branch origin/develop
 + commit id: "E"
 + commit id: "F"
 +</flow>
 +
 +
 +\\
 +''git merge --ff-only origin/develop''
 +<flow>
 +%%{init: { 'logLevel': 'debug', 'theme': 'default','themeVariables': {  'git0': '#6D97CA','git1': '#00ffff' }, 'gitGraph': {'showBranches': true, 'showCommitLabel':true,'mainBranchName': 'develop y origin/develop','rotateCommitLabel': false}} }%%
 +gitGraph
 + commit id: "A"
 + commit id: "B"
 + commit id: "C"
 + commit id: "D"
 + commit id: "E"
 + commit id: "F" 
 +</flow>
 +
  
 ==== git merge rama ==== ==== git merge rama ====
Línea 152: Línea 246:
 <sxh bash> <sxh bash>
   git fetch --prune   git fetch --prune
-  git checkout develop+  git switch develop
   git merge --ff-only origin/develop   git merge --ff-only origin/develop
  
   git fetch --prune   git fetch --prune
-  git checkout release+  git switch release
   git merge --ff-only origin/release   git merge --ff-only origin/release
  
   git fetch --prune   git fetch --prune
-  git checkout master+  git switch master
   git merge --ff-only origin/master   git merge --ff-only origin/master
 </sxh> </sxh>
Línea 171: Línea 265:
  
 <sxh bash> <sxh bash>
-  git checkout release+  git switch release
   git merge --ff-only develop   git merge --ff-only develop
  
-  git checkout master+  git switch master
   git merge --ff-only release   git merge --ff-only release
 </sxh> </sxh>
Línea 186: Línea 280:
 <sxh bash> <sxh bash>
   git fetch --prune   git fetch --prune
-  git checkout develop+  git switch develop
   git rebase origin/develop   git rebase origin/develop
 </sxh> </sxh>
Línea 208: Línea 302:
  
 <sxh bash> <sxh bash>
-  git checkout develop+  git switch develop
   git merge  --squash lorenzo_42   git merge  --squash lorenzo_42
   git commit -am "feat(#42):pantalla de Login"   git commit -am "feat(#42):pantalla de Login"
Línea 222: Línea 316:
  
 <sxh bash> <sxh bash>
-  git checkout lorenzo_42+  git switch lorenzo_42
   git merge develop   git merge develop
  
Línea 352: Línea 446:
  
 <sxh bash> <sxh bash>
-git checkout develop+git switch develop
 git rebase origin/develop git rebase origin/develop
 vi index.html  #Arreglar el conflicto vi index.html  #Arreglar el conflicto
Línea 382: Línea 476:
  
 <sxh bash> <sxh bash>
-git checkout develop+git switch develop
 git merge --squash Lorenzo_3 git merge --squash Lorenzo_3
 vi index.html  #Arreglar el conflicto vi index.html  #Arreglar el conflicto
Línea 407: Línea 501:
 </sxh> </sxh>
  
-Ahora debemos como antes arreglar el conflicto editando el fichero ''index.html'' hacer una cosa mas:+Ahora debemos como antes arreglar el conflicto editando el fichero ''index.html'' y el ''--continue'': 
  
 <sxh bash> <sxh bash>
 +  git add index.html 
   git merge --continue   git merge --continue
 </sxh> </sxh>
 +  
 +Es decir añadir el fichero que ha dado el conflicto con un ''git add'' y luego hacer un ''git merge --continue'' para que se acabe de mergear.
 +
  
  
Línea 417: Línea 516:
  
 <sxh bash> <sxh bash>
-git checkout Lorenzo_3+git switch Lorenzo_3
 git merge develop git merge develop
 vi index.html  #Arreglar el conflicto vi index.html  #Arreglar el conflicto
 +git add index.html 
 git merge --continue git merge --continue
 </sxh> </sxh>
 \\ \\
  
-===== Stash ===== 
-Hay veces que queremos guardar temporalmente los cambios para despues volver a ellos, por ejemplo si queremos cambiar de rama. 
- 
-git contiene una orden para hacer eso: 
-<sxh bash> 
-git stash 
-</sxh> 
- 
-Y si luego queremos recuperar los cambios se hace con: 
- 
-<sxh bash> 
-git stash pop 
-</sxh> 
  
 ===== Recetas ===== ===== Recetas =====
Línea 443: Línea 530:
  
 <sxh bash> <sxh bash>
-git fetch --prune && git checkout develop && git merge --ff-only origin/develop && git checkout release && git merge --ff-only origin/release && git checkout master && git merge --ff-only origin/master && git checkout develop+git fetch --prune && git switch develop && git merge --ff-only origin/develop && git switch release && git merge --ff-only origin/release && git switch master && git merge --ff-only origin/master && git switch develop
 </sxh> </sxh>
  
Línea 449: Línea 536:
  
 <sxh bash> <sxh bash>
-git checkout release && git merge --ff-only develop && git checkout master && git merge --ff-only release && git checkout develop+git switch release && git merge --ff-only develop && git switch master && git merge --ff-only release && git switch develop
 </sxh> </sxh>
  
Línea 455: Línea 542:
  
 <sxh bash> <sxh bash>
-git checkout master && git push && git checkout release && git push && git checkout develop && git push+git switch master && git push && git switch release && git push && git switch develop && git push
 </sxh> </sxh>
  
clase/daw/daw/2eval/tema06.1637090341.txt.gz · Última modificación: 2021/11/16 20:19 por admin