tech:git:start

Diferències

Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.

Enllaç a la visualització de la comparació

Ambdós costats versió prèvia Revisió prèvia
Següent revisió
Revisió prèvia
tech:git:start [30/06/2025 01:35] – [otros] matetech:git:start [10/07/2025 06:06] (actual) – [todo] mate
Línia 3: Línia 3:
  
 == related == related
-{{topic>git}}+=== cursos 
 +{{topic>git +cursos}} 
 +=== + info 
 +{{NEWPAGE>tech:git}} 
 +{{topic>git -cursos}}
   * [[tech:git:server]]   * [[tech:git:server]]
   * [[tech:git:curs]]   * [[tech:git:curs]]
Línia 22: Línia 26:
   * [[https://git-scm.com/book/es/v2]]   * [[https://git-scm.com/book/es/v2]]
   * [[https://esparta.github.io/gitimmersion-spanish/index.html]]   * [[https://esparta.github.io/gitimmersion-spanish/index.html]]
-  * [[tech:git:dotfiles]]+  * [[https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud|git bitbucket tutorial]] 
 +  * [[https://ohshitgit.com/es]] 
 == todo == todo
 <callout type="warning" title="git extras" icon="true">https://github.com/tj/git-extras/</callout> <callout type="warning" title="git extras" icon="true">https://github.com/tj/git-extras/</callout>
Línia 28: Línia 34:
 <callout type="info" title="git resumen" icon="true">http://rogerdudler.github.io/git-guide/index.es.html</callout> <callout type="info" title="git resumen" icon="true">http://rogerdudler.github.io/git-guide/index.es.html</callout>
 <callout type="info" title="git command tricks" icon="true">https://medium.freecodecamp.org/bash-shortcuts-to-enhance-your-git-workflow-5107d64ea0ff</callout> <callout type="info" title="git command tricks" icon="true">https://medium.freecodecamp.org/bash-shortcuts-to-enhance-your-git-workflow-5107d64ea0ff</callout>
-  * git-config condicional [[https://www.kevinkuszyk.com/2018/12/10/git-tips-6-using-git-with-multiple-email-addresses/]] +<callout type="info" title="git-config condicional" icon="true">[[https://www.kevinkuszyk.com/2018/12/10/git-tips-6-using-git-with-multiple-email-addresses/]]</callout>
- +
-== config +
-  * ubicación: +
-    * system : /etc/gitconfig [--system] +
-    * global : ~/.gitconfig [--global] +
-    * repo : .git/config +
-    * <code bash>git config --list --show-origin</code> +
-  * ''git config [--global] --list'' : si omitimos el ámbito, muestra todas las configuraciones disponibles +
-  * ''git config --global user.name "Mi Nombre"'' +
-  * ''git config --global user.email "mi@email"'' +
-  * ''git config --global http.sslVerify false'' : no verifica el certificado en peticiones por *https* +
-  * ''git config --global core.editor "%%'$(which vim)'%%"'' : asignar VIM como editor por defecto +
-  * ''git config credential.helper store'' : store contraseñas (texto plano) autenticación +
-    * ''git config --global credential.helper %%'cache --timeout 7200'%%'' +
-    * ''git config credential.helper libsecret''? +
- +
-== otros +
-  * [[tech:git:autopush]] +
-  * [[tech:git:diff]] +
-  * [[tech:git:lfs]] +
- +
-== errores +
-  * [[tech:git:error:thread]] +
-== tips +
-  * HEAD == @ +
-  * HEAD^ : commit anterior al HEAD +
-  * HEAD@{1.month} +
-  * - (guión) : te devuelve a la rama que acabas de dejar +
- +
-== comandos interesantes +
-  * [[tech:git:replica]] +
-  * [[tech:git:submodule]] +
-  * [[tech:git:fusion]] +
-  * [[tech:git:difftool]] +
-  * [[https://www.atlassian.com/git/tutorials/learn-git-with-bitbucket-cloud|git bitbucket tutorial]] +
-  * [[https://ohshitgit.com/es]] +
- +
-=== git fetch VS git pull +
-  * git pull = git fetch (+ git checkout) + git merge +
-  * modo seguro:<code bash>git fetch origin +
-git log --oneline main..origin/main +
-git checkout main +
-git log origin/main +
-git merge origin/main</code> +
- +
-  * [[https://www.atlassian.com/es/git/tutorials/syncing/git-fetch]] +
-  * [[https://www.atlassian.com/es/git/tutorials/using-branches/git-checkout]] +
-  * [[https://www.atlassian.com/es/git/tutorials/using-branches/git-merge]] +
-  * [[https://www.atlassian.com/es/git/tutorials/syncing/git-pull]] +
-=== ramas +
-<code bash renombrado rama en local y remoto> +
-git checkout <old_name> && git branch -m <new_name> # o git branch -m <old_name> <new_name> +
-git push -u origin <new_name> # y comprobar en remoto que todo ha ido bien +
-git push origin :<old_name> # elimina la rama vieja del remoto! +
-</code> +
- +
-<code bash mover rama, trayendo solo los commits que se hayan realizado > +
-git ck -b rama_destino +
-git cherry-pick <commit1>..<commit2> # commit1^..commit2 para incluir commit1 en el movimiento +
-git push origin rama_destino # envíamos los cambios +
-git push origin :rama_origen # elimina la rama mal colocada +
-</code> +
- +
-<code bash traer los cambios de rama develop a la actual> +
-git pull --rebase origin develop +
-</code> +
- +
-<code bash comandos con TAGs> +
-git tag [-l] +
-git show <tag> +
-git tag -a <TAG> -m "<MENSAJE>" # tag local annotated +
-git push origin <TAG> # subir tag a remoto +
-git -d <tag> # borrar tag local +
-git push --delete origin <TAG> # borrado tag en remoto +
-</code> +
- +
-<code bash actualizar listado ramas> +
-git remote update origin --prune +
-git branch -a +
-</code> +
-/via: [[https://stackoverflow.com/questions/36358265/when-does-git-refresh-the-list-of-remote-branches]] +
- +
-<code bash (ohshitgit) Sacar commit de una rama para llevarlo a una nueva> +
-git branch nueva-rama +
-git reset HEAD~ --hard +
-git checkout nueva-rama +
-</code> +
- +
-<code bash (ohshitgit) Commit en rama equivocada> +
-# deshaz el útlimo commit, pero deja los cambio disponibles +
-git reset HEAD~ --soft +
-git stash +
-# muevete a la rama correcta +
-git checkout nombre-de-la-rama-correcta +
-git stash pop +
-git add . # or add individual files +
-git commit -m "your message here"; +
-# ahora tus cambios estan en la rama correcta +
-</code> +
-<code bash (ohshitgit) Commit en rama equivocada - cherry-pick> +
-git checkout nombre-de-la-rama-correcta +
-# coge el último commit de master +
-git cherry-pick master +
-# borralo de master +
-git checkout master +
-git reset HEAD~ --hard +
-</code> +
- +
-=== pequeños cambios en commits (no push) +
-<code bash (ohshitgit) agregar cambios al último commit>git add . +
-git commit --amend --no-edit</code> +
- +
-<code bash (ohshitgit) cambiar mensaje último commit>git commit --amend</code> +
-=== retroceder o cambiar el pasado(rebase/reset) +
-<code bash (ohsgitgit) todo lo hecho, en todas las ramas>git reflog # cada entrada tiene un HEAD@{index}</code> +
-<code bash (ohsgitgit) vuelta atrás>git reset HEAD@{index}</code> +
-<code bash cambiar el mensaje de un commit (el último -1) > +
-git rebase -i HEAD^ # y marcar con reword +
-</code> +
- +
-<code bash; fusionar varios commits > +
-git rebase -i <commit>^ #  con ^ se incluye el que indiquemos +
-git rebase -i HEAD~n # los últimos n +
-# marcar con SQUASH aquellos que queramos fusionar, dejando el mayor ancestro como destinatario de todos ellos +
-# git push origin <rama> -f # fuerza la subida de los cambios +
-</code> +
- +
-<code bash anular último commit (se pierde)> +
-git rebase -i HEAD^ # y marcar con drop +
-</code> +
- +
-<code bash anular último commit dejando en working area> +
-git reset HEAD~1 +
-</code> +
- +
-=== ficheros +
-<code bash; recuperar un fichero > +
-git checkout <COMMIT|HEAD|HEAD^> <path_file> +
-</code> +
- +
-<code bash (ohshitgit) recuperar un fichero > +
-# busca el hash del commit anterior de cuando se cambio el archivo +
-git log +
-# usa las flechas para moverte para arriba y abajo en la historia +
-# una vez que encontraste el commit, guarda su hash +
-git checkout [hash guardado] -- path/to/file +
-# la version anterior del archivo estará en tu index +
-git commit -m "Waw, no tienes que hacer copiar-pegar para deshacer" +
-</code> +
- +
-<code bash ficheros modificados en commit concreto> +
-git log --oneline --max-count=10 +
-git diff-tree --no-commit-id --name-only -r <COMMIT_ID> +
-git show --pretty="" --name-only <COMMIT_ID> +
-</code> +
- +
-<code bash seguir traza cambios a fichero> +
-git log --follow -p -- <FILE> +
-git log --stat <FILE> +
-</code> +
-  * https://git-scm.com/docs/git-log+
  
-<code bash>git whatchanged [<FILE>]</code> 
-  * [[https://git-scm.com/docs/git-whatchanged]] 
-  * mantenido por razones históricas 
  
-==== diferencias entre commits 
-  * (ohshitgit) diferencias de ficheros en **staged**:<code bash>git diff --staged</code> 
-  * diferencia de ficheros entre dos commits:<code bash>git diff --name-only SHA1 SHA2</code> 
-  * generar ZIP con ficheros cambiados entre 2 commits:<code bash>git archive --output=file.zip HEAD $(git diff --name-only SHA1 SHA2)</code> 
-  * /via:[[https://www.solucionex.com/blog/ficheros-modificados-entre-dos-commits-con-git]] 
-==== recuperar 
-  * localizar fichero: <code bash>git log -- <fichero></code> 
-  * recuperar fichero: <code bash>git checkout <COMMIT_ID> -- <fichero></code> 
-  * [[https://recoverit.wondershare.es/file-recovery/recover-files-from-local-repository-git.html]] 
  
-=== búsquedas 
-<code bash localizar fichero>git log -- <fichero></code> 
-<code bash seguir traza cambios a fichero>git log --follow -p -- <FILE></code> 
-<code bash buscar ficheros y estatus>git log --name-status -- "*<FILE>*"</code> 
-  * ''--'' indica a git que lo que viene a continuación son rutas de ficheros y no ramas 
-<code bash buscar líneas de código>git log -S"Hello, World!"</code> 
-/via: [[https://www.atlassian.com/git/tutorials/git-log]] 
  • tech/git/start.1751272501.txt.gz
  • Darrera modificació: 30/06/2025 01:35
  • per mate