Diferències
Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.
Ambdós costats versió prèvia Revisió prèvia Següent revisió | Revisió prèvia | ||
tech:git:start [25/04/2022 02:33] – [comandos interesantes] mate | tech:git:start [09/05/2025 04:09] (actual) – [related] mate | ||
---|---|---|---|
Línia 5: | Línia 5: | ||
{{topic> | {{topic> | ||
* [[tech: | * [[tech: | ||
+ | * [[tech: | ||
+ | * [[tech: | ||
== cheatsheet | == cheatsheet | ||
Línia 17: | Línia 19: | ||
* [[https:// | * [[https:// | ||
+ | == doc | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
== todo | == todo | ||
<callout type=" | <callout type=" | ||
Línia 43: | Línia 48: | ||
* [[tech: | * [[tech: | ||
* [[tech: | * [[tech: | ||
+ | |||
+ | == errores | ||
+ | * [[tech: | ||
== tips | == tips | ||
* HEAD == @ | * HEAD == @ | ||
Línia 55: | Línia 63: | ||
* [[tech: | * [[tech: | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// | ||
- | <code bash; renombrado rama en local y remoto> | + | === git fetch VS git pull |
+ | * git pull = git fetch (+ git checkout) + git merge | ||
+ | * modo seguro:< | ||
+ | git log --oneline main..origin/ | ||
+ | git checkout main | ||
+ | git log origin/ | ||
+ | git merge origin/ | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | === ramas | ||
+ | <code bash renombrado rama en local y remoto> | ||
git checkout < | git checkout < | ||
git push -u origin < | git push -u origin < | ||
Línia 62: | Línia 84: | ||
</ | </ | ||
- | <code bash; mover rama, trayendo solo los commits que se hayan realizado > | + | <code bash mover rama, trayendo solo los commits que se hayan realizado > |
git ck -b rama_destino | git ck -b rama_destino | ||
git cherry-pick < | git cherry-pick < | ||
Línia 69: | Línia 91: | ||
</ | </ | ||
- | <code bash; cambiar el mensaje de un commit (el último -1) > | + | <code bash traer los cambios de rama develop a la actual> |
+ | git pull --rebase origin develop | ||
+ | </ | ||
+ | |||
+ | <code bash comandos con TAGs> | ||
+ | git tag [-l] | ||
+ | git show < | ||
+ | git tag -a <TAG> -m "< | ||
+ | git push origin <TAG> # subir tag a remoto | ||
+ | git -d <tag> # borrar tag local | ||
+ | git push --delete origin <TAG> # borrado tag en remoto | ||
+ | </ | ||
+ | |||
+ | <code bash actualizar listado ramas> | ||
+ | git remote update origin --prune | ||
+ | git branch -a | ||
+ | </ | ||
+ | /via: [[https:// | ||
+ | |||
+ | <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 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 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 | ||
+ | </ | ||
+ | |||
+ | === pequeños cambios en commits (no push) | ||
+ | <code bash (ohshitgit) agregar cambios al último commit> | ||
+ | git commit --amend --no-edit</ | ||
+ | |||
+ | <code bash (ohshitgit) cambiar mensaje último commit> | ||
+ | === retroceder o cambiar el pasado(rebase/ | ||
+ | <code bash (ohsgitgit) todo lo hecho, en todas las ramas> | ||
+ | <code bash (ohsgitgit) vuelta atrás> | ||
+ | <code bash cambiar el mensaje de un commit (el último -1) > | ||
git rebase -i HEAD^ # y marcar con reword | git rebase -i HEAD^ # y marcar con reword | ||
</ | </ | ||
Línia 80: | Línia 155: | ||
</ | </ | ||
- | <code bash; anular último commit > | + | <code bash anular último commit |
- | git rebase -i HEAD^ # y marcar con reword | + | git rebase -i HEAD^ # y marcar con drop |
</ | </ | ||
- | <code bash; anular último commit dejando en working area> | + | |
+ | <code bash anular último commit dejando en working area> | ||
git reset HEAD~1 | git reset HEAD~1 | ||
</ | </ | ||
+ | === ficheros | ||
<code bash; recuperar un fichero > | <code bash; recuperar un fichero > | ||
git checkout < | git checkout < | ||
</ | </ | ||
- | <code bash; traer los cambios | + | <code bash (ohshitgit) recuperar un fichero > |
- | git pull --rebase origin develop | + | # busca el hash del commit anterior |
+ | 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/ | ||
+ | # la version anterior del archivo estará en tu index | ||
+ | git commit | ||
</ | </ | ||
- | <code bash; comandos con TAGs> | + | <code bash ficheros modificados en commit concreto> |
- | git tag [-l] | + | |
- | git show < | + | |
- | git tag -a <TAG> -m "< | + | |
- | git push origin <TAG> # subir tag a remoto | + | |
- | git -d <tag> # borrar tag local | + | |
- | git push --delete origin <TAG> # borrado tag en remoto | + | |
- | </ | + | |
- | + | ||
- | <code bash; ficheros modificados en commit concreto> | + | |
git log --oneline --max-count=10 | git log --oneline --max-count=10 | ||
git diff-tree --no-commit-id --name-only -r < | git diff-tree --no-commit-id --name-only -r < | ||
Línia 110: | Línia 184: | ||
</ | </ | ||
- | <code bash; seguir traza cambios a fichero> | + | <code bash seguir traza cambios a fichero> |
git log --follow -p -- < | git log --follow -p -- < | ||
+ | git log --stat < | ||
</ | </ | ||
+ | * https:// | ||
- | <code bash; actualizar listado ramas> | + | <code bash>git whatchanged [< |
- | git remote update origin | + | * [[https://git-scm.com/ |
- | git branch | + | * mantenido por razones históricas |
- | </ | + | |
- | /via: [[https://stackoverflow.com/questions/36358265/when-does-git-refresh-the-list-of-remote-branches]] | + | ==== diferencias entre commits |
+ | * (ohshitgit) diferencias de ficheros en **staged**:< | ||
+ | * diferencia de ficheros entre dos commits:< | ||
+ | * generar ZIP con ficheros cambiados entre 2 commits:< | ||
+ | * / | ||
+ | ==== recuperar | ||
+ | * localizar fichero: <code bash>git log -- < | ||
+ | * recuperar fichero: <code bash>git checkout < | ||
+ | * [[https:// | ||
+ | |||
+ | === búsquedas | ||
+ | <code bash localizar fichero>git log -- < | ||
+ | <code bash seguir traza cambios a fichero> | ||
+ | <code bash buscar ficheros y estatus> | ||
+ | * '' | ||
+ | <code bash buscar líneas de código> | ||
+ | /via: [[https:// |