Skip to content

Instantly share code, notes, and snippets.

@nerea91
Forked from jelcaf/Operaciones-Git
Created December 30, 2015 16:13
Show Gist options
  • Save nerea91/2a08a80c892d3dfa21f5 to your computer and use it in GitHub Desktop.
Save nerea91/2a08a80c892d3dfa21f5 to your computer and use it in GitHub Desktop.

Revisions

  1. @jelcaf jelcaf renamed this gist Oct 8, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @jelcaf jelcaf revised this gist May 28, 2014. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -114,6 +114,9 @@ pick 2a3cdf7 Commit message 2
    # f, fixup = like "squash", but discard this commit's log message
    # x, exec = run command (the rest of the line) using shell

    # Establecer la fecha de los commits anterior al rebase => git committer date = git author date
    git filter-branch --env-filter 'GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE; export GIT_COMMITTER_DATE' <sha1>..HEAD

    ##############################################
    # Recuperarse de un desastre
    http://www.bluemangolearning.com/blog/2009/03/recovering-from-a-disastrous-git-rebase-mistake/
  3. @jelcaf jelcaf revised this gist Feb 26, 2014. 1 changed file with 19 additions and 1 deletion.
    20 changes: 19 additions & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -93,9 +93,27 @@ git branch -r --contains $commit
    # Deshacer el último commit (dejándolo como estaba con los archivos añadidos y demás)
    git reset --soft HEAD^

    # Deshacer commits (seleccionamos los que queremos)
    ##############################################
    # Reescribiendo la "historia"
    # - Deshacer commits
    # - Unir commits
    # - Reordenar commits
    # - ...
    git rebase -i HEAD~10 # Esto mira los 10 últimos

    # Y veremos algo como esto:
    pick ce2b738 Commit message 1
    pick 2a3cdf7 Commit message 2

    # Y podremos realizar las siguientes operaciones sobre los commits
    # inlcuyendo reordenar los commits
    # p, pick = use commit
    # r, reword = use commit, but edit the commit message
    # e, edit = use commit, but stop for amending
    # s, squash = use commit, but meld into previous commit
    # f, fixup = like "squash", but discard this commit's log message
    # x, exec = run command (the rest of the line) using shell

    ##############################################
    # Recuperarse de un desastre
    http://www.bluemangolearning.com/blog/2009/03/recovering-from-a-disastrous-git-rebase-mistake/
  4. @jelcaf jelcaf revised this gist Feb 26, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -38,10 +38,11 @@ git branch -d $branch
    # Eliminar una rama remota
    git push origin :$branch

    # Eliminar las ramas remotas que ya no existan en origin
    # Eliminar las ramas remotas que ya no existan en origin (Ambos comandos hacen lo mismo)
    # Ejecutar con --dry-run para ver los cambios que realizará
    git fetch -p
    git remote prune origin
    #############################################

    # Cambiar el nombre de una rama
    git branch -m $nombre_rama_anterior $nombre_rama_nuevo
  5. @jelcaf jelcaf revised this gist Feb 26, 2014. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -38,6 +38,11 @@ git branch -d $branch
    # Eliminar una rama remota
    git push origin :$branch

    # Eliminar las ramas remotas que ya no existan en origin
    # Ejecutar con --dry-run para ver los cambios que realizará
    git fetch -p
    git remote prune origin

    # Cambiar el nombre de una rama
    git branch -m $nombre_rama_anterior $nombre_rama_nuevo

  6. @jelcaf jelcaf revised this gist Mar 13, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -87,6 +87,9 @@ git branch -r --contains $commit
    # Deshacer el último commit (dejándolo como estaba con los archivos añadidos y demás)
    git reset --soft HEAD^

    # Deshacer commits (seleccionamos los que queremos)
    git rebase -i HEAD~10 # Esto mira los 10 últimos

    ##############################################
    # Recuperarse de un desastre
    http://www.bluemangolearning.com/blog/2009/03/recovering-from-a-disastrous-git-rebase-mistake/
  7. @jelcaf jelcaf revised this gist Nov 28, 2012. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -84,6 +84,9 @@ git log origin/master..master
    # list remote branches that contain $commit
    git branch -r --contains $commit

    # Deshacer el último commit (dejándolo como estaba con los archivos añadidos y demás)
    git reset --soft HEAD^

    ##############################################
    # Recuperarse de un desastre
    http://www.bluemangolearning.com/blog/2009/03/recovering-from-a-disastrous-git-rebase-mistake/
  8. @jelcaf jelcaf revised this gist Jun 1, 2012. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -78,6 +78,12 @@ git pull --rebase origin $rama
    git push origin rama
    git stash pop

    # list commits not pushed to the origin yet
    git log origin/master..master

    # list remote branches that contain $commit
    git branch -r --contains $commit

    ##############################################
    # Recuperarse de un desastre
    http://www.bluemangolearning.com/blog/2009/03/recovering-from-a-disastrous-git-rebase-mistake/
  9. @jelcaf jelcaf revised this gist Feb 17, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -43,7 +43,7 @@ git branch -m $nombre_rama_anterior $nombre_rama_nuevo

    #############################################
    # Ignorar el salto de línea en Git http://help.github.com/line-endings/
    git config --system core.autocrlf true
    git config --global core.autocrlf input

    #############################################
    # Copiar un commit determinado a una rama cualquiera
  10. @jelcaf jelcaf revised this gist Feb 17, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -70,7 +70,7 @@ git reset --soft HEAD~1
    git revert HEAD

    ##############################################
    # Subir a la rama Commits parciales
    # Subir a la rama Commits parciales (los ficheros que no añado se quedan en el stash y se recuperan luego)
    git add $file
    git commit -m "Mensaje"
    git stash
  11. @jelcaf jelcaf revised this gist Feb 17, 2012. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -69,6 +69,15 @@ git reset --soft HEAD~1
    # Deshacer el último commit (habiendo hecho ya un push)
    git revert HEAD

    ##############################################
    # Subir a la rama Commits parciales
    git add $file
    git commit -m "Mensaje"
    git stash
    git pull --rebase origin $rama
    git push origin rama
    git stash pop

    ##############################################
    # Recuperarse de un desastre
    http://www.bluemangolearning.com/blog/2009/03/recovering-from-a-disastrous-git-rebase-mistake/
  12. @jelcaf jelcaf revised this gist Feb 15, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,8 @@ git reset --HARD $SHA1
    #############################################
    # Ver y descargar Ramas remotas
    git remote show origin
    # Si hay alguna rama de la cual no tengamos los datos aún
    git fetch origin
    # Obtener la rama remota
    git checkout --track -b $rama origin/$rama
    # más simple
  13. @jelcaf jelcaf revised this gist Feb 15, 2012. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,12 @@ git reset --HARD $SHA1

    #############################################
    # Ver y descargar Ramas remotas
    git remote show origin
    # Obtener la rama remota
    git checkout --track -b $rama origin/$rama
    # más simple
    git checkout -t origin/$rama

    git branch -a
    # * master
    # remotes/origin/HEAD -> origin/master
    @@ -16,6 +22,7 @@ git branch -a
    # remotes/origin/fallo_registro
    # remotes/origin/master
    git checkout -b baremacion remotes/origin/baremacion
    #############################################

    # Crear una rama basada en el HEAD
    git branch $branch
  14. @jelcaf jelcaf revised this gist Feb 15, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,7 @@ git branch -d $branch
    git push origin :$branch

    # Cambiar el nombre de una rama
    git branch -m $nombre-rama-anterior $nombre-rama-nuevo
    git branch -m $nombre_rama_anterior $nombre_rama_nuevo

    #############################################
    # Ignorar el salto de línea en Git http://help.github.com/line-endings/
  15. @jelcaf jelcaf revised this gist Feb 15, 2012. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,9 @@ git branch -d $branch
    # Eliminar una rama remota
    git push origin :$branch

    # Cambiar el nombre de una rama
    git branch -m $nombre-rama-anterior $nombre-rama-nuevo

    #############################################
    # Ignorar el salto de línea en Git http://help.github.com/line-endings/
    git config --system core.autocrlf true
  16. @jelcaf jelcaf revised this gist Feb 6, 2012. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -55,4 +55,8 @@ git push --tags
    git reset --soft HEAD~1

    # Deshacer el último commit (habiendo hecho ya un push)
    git revert HEAD
    git revert HEAD

    ##############################################
    # Recuperarse de un desastre
    http://www.bluemangolearning.com/blog/2009/03/recovering-from-a-disastrous-git-rebase-mistake/
  17. @jelcaf jelcaf revised this gist Jan 30, 2012. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -49,3 +49,10 @@ git tag -a v1.2 $SHA1

    # Subir tags al repositorio
    git push --tags

    ##############################################
    # Deshacer el último commit (sin haber hecho push)
    git reset --soft HEAD~1

    # Deshacer el último commit (habiendo hecho ya un push)
    git revert HEAD
  18. @jelcaf jelcaf revised this gist Jan 12, 2012. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,12 @@ git branch -a
    # remotes/origin/master
    git checkout -b baremacion remotes/origin/baremacion

    # Crear una rama basada en el HEAD
    git branch $branch

    # Crear una nueva rama basada en el branch $other
    git checkout -b $new_branch $other

    # Eliminar una rama local
    git branch -d $branch

  19. @jelcaf jelcaf revised this gist Jan 10, 2012. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,9 @@ git checkout -b baremacion remotes/origin/baremacion
    # Eliminar una rama local
    git branch -d $branch

    # Eliminar una rama remota
    git push origin :$branch

    #############################################
    # Ignorar el salto de línea en Git http://help.github.com/line-endings/
    git config --system core.autocrlf true
  20. @jelcaf jelcaf revised this gist Dec 22, 2011. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,9 @@ git branch -a
    # remotes/origin/master
    git checkout -b baremacion remotes/origin/baremacion

    # Eliminar una rama local
    git branch -d $branch

    #############################################
    # Ignorar el salto de línea en Git http://help.github.com/line-endings/
    git config --system core.autocrlf true
  21. @jelcaf jelcaf revised this gist Dec 21, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -18,8 +18,8 @@ git branch -a
    git checkout -b baremacion remotes/origin/baremacion

    #############################################
    # Ignorar el salto de línea en Git
    git config --system core.autocrlf false
    # Ignorar el salto de línea en Git http://help.github.com/line-endings/
    git config --system core.autocrlf true

    #############################################
    # Copiar un commit determinado a una rama cualquiera
  22. @jelcaf jelcaf revised this gist Dec 21, 2011. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,10 @@
    # Push de la rama actual
    git push origin $rama_actual

    #############################################
    # Volver a un commit anterior, descartando los cambios
    git reset --HARD $SHA1

    #############################################
    # Ver y descargar Ramas remotas
    git branch -a
  23. @jelcaf jelcaf revised this gist Dec 20, 2011. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -21,3 +21,15 @@ git config --system core.autocrlf false
    # Copiar un commit determinado a una rama cualquiera
    git checkout $rama
    git cherry-pick $SHA1

    #############################################
    # Trabajando con tags

    # Ver los tags locales
    git tag

    # Añadir un tag
    git tag -a v1.2 $SHA1

    # Subir tags al repositorio
    git push --tags
  24. @jelcaf jelcaf revised this gist Dec 20, 2011. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -15,4 +15,9 @@ git checkout -b baremacion remotes/origin/baremacion

    #############################################
    # Ignorar el salto de línea en Git
    git config --system core.autocrlf false
    git config --system core.autocrlf false

    #############################################
    # Copiar un commit determinado a una rama cualquiera
    git checkout $rama
    git cherry-pick $SHA1
  25. @jelcaf jelcaf revised this gist Dec 20, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #############################################
    # Push de la rama actual
    git push origin <$rama_actual>
    git push origin $rama_actual

    #############################################
    # Ver y descargar Ramas remotas
  26. @jelcaf jelcaf revised this gist Dec 20, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #############################################
    # Push de la rama actual
    git push origin
    git push origin <$rama_actual>

    #############################################
    # Ver y descargar Ramas remotas
  27. @jelcaf jelcaf revised this gist Dec 15, 2011. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    #############################################
    # Push de la rama actual
    git push origin

    #############################################
    # Ver y descargar Ramas remotas
    git branch -a
  28. @jelcaf jelcaf revised this gist Dec 14, 2011. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    #############################################
    # Ver y descargar Ramas remotas
    git branch -a
    # * master
    @@ -6,8 +7,8 @@ git branch -a
    # remotes/origin/bootstrap
    # remotes/origin/fallo_registro
    # remotes/origin/master

    git checkout -b baremacion remotes/origin/baremacion

    #############################################
    # Ignorar el salto de línea en Git
    git config --system core.autocrlf false
  29. @jelcaf jelcaf revised this gist Dec 14, 2011. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -7,4 +7,7 @@ git branch -a
    # remotes/origin/fallo_registro
    # remotes/origin/master

    git checkout -b baremacion remotes/origin/baremacion
    git checkout -b baremacion remotes/origin/baremacion

    # Ignorar el salto de línea en Git
    git config --system core.autocrlf false
  30. @jelcaf jelcaf revised this gist Dec 14, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    # Ver y descargar Ramas remotas
    git branch -a
    # * master
    # remotes/origin/HEAD -> origin/master