Chuleta de comandos de Git
Explora más de 40 comandos de Git organizados en 10 categorías: Configuración inicial, Preparación, Ramas, Compartir, Inspección, Deshacer cambios, Guardado temporal (stash), Reescribir el historial y Avanzado. Busca por nombre de comando, descripción, opción o ejemplo. Haz clic en cualquier comando para copiarlo al portapapeles al instante. Sin registro.
Browse 44 Git commands organized by category. Search by command name, description, flags, or examples. Click any command or example to copy it to your clipboard. Expand any card to see available flags.
Setup & Config
5 commandsgit config --global user.name "[name]"Set the name that will be attached to your commits and tags.
git config --global user.name "Jane Doe"git config --global user.email "[email]"Set the email address that will be attached to your commits and tags.
git config --global user.email "[email protected]"git config --global core.editor "[editor]"Set the default text editor for commit messages.
git config --global core.editor "code --wait"git config --listList all Git configuration settings currently in effect.
git config --listgit config --global alias.[alias] "[command]"Create a shortcut alias for a Git command.
git config --global alias.st statusGetting Started
2 commandsgit initInitialize a new local Git repository in the current directory.
git initgit clone [url]Clone a remote repository into a new local directory.
git clone https://github.com/user/repo.gitStaging & Snapshots
6 commandsgit statusShow the working tree status - staged, unstaged, and untracked files.
git statusgit add [file]Stage a file or directory for the next commit.
git add src/index.tsgit commit -m "[message]"Record staged changes to the repository with a commit message.
git commit -m "feat: add user authentication"git diffShow unstaged changes between your working directory and the index.
git diffgit rm [file]Remove a file from the working tree and stage the deletion.
git rm old-file.txtgit mv [old] [new]Move or rename a file and stage the change.
git mv old-name.ts new-name.tsBranching & Merging
6 commandsgit branchList, create, or delete branches.
git branch feature/logingit checkout [branch]Switch to an existing branch or restore working tree files.
git checkout maingit switch [branch]Switch to a branch (modern replacement for git checkout for branch switching).
git switch feature/logingit merge [branch]Merge the specified branch into the current branch.
git merge feature/logingit rebase [branch]Reapply commits on top of another base branch.
git rebase maingit cherry-pick [commit]Apply the changes from a specific commit onto the current branch.
git cherry-pick a1b2c3dSharing & Updating
4 commandsgit remote add [name] [url]Add a new remote repository connection.
git remote add origin https://github.com/user/repo.gitgit fetch [remote]Download objects and refs from a remote without merging.
git fetch origingit pull [remote] [branch]Fetch from a remote and integrate (merge or rebase) into the current branch.
git pull origin maingit push [remote] [branch]Upload local branch commits to the remote repository.
git push origin mainInspection & Comparison
4 commandsgit logShow the commit history for the current branch.
git log --oneline --graph --allgit show [commit]Show information about a commit, tag, or tree object.
git show a1b2c3dgit blame [file]Show what revision and author last modified each line of a file.
git blame src/index.tsgit tag [name]Create, list, or delete tags.
git tag v1.0.0Undoing Changes
4 commandsgit restore [file]Discard changes in the working directory (modern replacement for checkout --).
git restore src/index.tsgit revert [commit]Create a new commit that undoes the changes from a previous commit.
git revert a1b2c3dgit reset [commit]Reset the current HEAD to a specified state.
git reset --soft HEAD~1git cleanRemove untracked files from the working directory.
git clean -fdStashing
5 commandsgit stashTemporarily save uncommitted changes to a stash stack.
git stashgit stash popApply the most recent stash and remove it from the stash stack.
git stash popgit stash listList all stashed changesets.
git stash listgit stash apply [stash]Apply a stash without removing it from the stash stack.
git stash apply stash@{2}git stash drop [stash]Remove a single stash entry from the stash stack.
git stash drop stash@{0}Rewriting History
3 commandsgit commit --amendModify the most recent commit - change message or add staged changes.
git commit --amend -m "fix: corrected typo in auth module"git rebase -i [base]Interactively rebase - reorder, squash, edit, or drop commits.
git rebase -i HEAD~3git reflogShow a log of all HEAD movements - useful for recovering lost commits.
git reflogAdvanced
5 commandsgit bisect startUse binary search to find the commit that introduced a bug.
git bisect start
git bisect bad
git bisect good v1.0git submodule add [url]Add a Git repository as a submodule inside another repository.
git submodule add https://github.com/user/lib.git libs/libgit worktree add [path] [branch]Check out a branch into a new working directory without cloning.
git worktree add ../hotfix hotfix/urgentgit archive [branch]Create a tar or zip archive of a tree from a branch or commit.
git archive --format=zip HEAD > release.zipgit shortlogSummarize git log output grouped by author.
git shortlog -sn¿Por qué usar nuestra chuleta de comandos de Git?
- Búsqueda instantánea de comandos de Git: encuentra cualquier comando de Git al instante buscando nombres de comandos, descripciones, opciones o ejemplos. Nuestra chuleta de comandos de Git busca en los más de 40 comandos y sus opciones en milisegundos: sin recargar páginas ni esperas.
- Chuleta de Git online segura: nuestra chuleta de comandos de Git se ejecuta por completo en tu navegador sin peticiones al servidor. Tus búsquedas e interacciones nunca salen de tu dispositivo, lo que garantiza una privacidad total cuando usas nuestra chuleta de Git online.
- Chuleta de Git - Sin instalación: usa nuestra chuleta de comandos de Git directamente en cualquier navegador, sin descargas, plugins ni cuenta. Consulta comandos de Git desde cualquier dispositivo (escritorio, tableta o móvil) totalmente gratis.
- Comandos, opciones y ejemplos: cada entrada de nuestra chuleta de comandos de Git incluye una descripción, un ejemplo real y opciones expandibles con explicaciones. Haz clic en cualquier comando o ejemplo para copiarlo al portapapeles al instante.
Casos de uso habituales de la chuleta de comandos de Git
- Aprender Git por primera vez: usa nuestra chuleta de comandos de Git para aprender los comandos más importantes en contexto. Cada comando incluye una descripción en lenguaje sencillo y un ejemplo real, lo que facilita entender qué hace cada comando antes de ejecutarlo.
- Recuperarse de errores: busca en nuestra chuleta de Git «undo», «revert» o «reset» para encontrar rápidamente el comando adecuado para tu situación. La categoría Deshacer cambios cubre git restore, git revert, git reset y git clean con explicaciones de opciones.
- Revisión de código y colaboración: consulta comandos de Git para flujos de trabajo con ramas, fusiones y rebase. Nuestra chuleta de comandos de Git cubre git branch, git merge, git rebase y git cherry-pick con todas sus opciones importantes.
- Scripts de CI/CD y automatización: encuentra la sintaxis exacta de los comandos de Git para tus scripts de automatización. Busca opciones como «--no-ff», «--force-with-lease» o «--depth» para obtener el formato preciso que necesita tu pipeline.
- Depuración e inspección: usa la categoría Inspección y comparación para encontrar los comandos git log, git blame, git show y git diff con sus opciones más útiles. Copia el comando exacto que necesites para investigar el historial de commits o los cambios de archivos.
- Flujos de trabajo avanzados de Git: explora la categoría Avanzado para los comandos git bisect, git submodule, git worktree y git archive. Nuestra chuleta de Git cubre estos comandos menos comunes pero potentes con ejemplos y explicaciones de opciones.
¿Qué es Git?
Git es un sistema de control de versiones distribuido que registra los cambios en el código fuente durante el desarrollo de software. Creado por Linus Torvalds en 2005, Git permite que varios desarrolladores trabajen en el mismo código base a la vez, mantengan un historial completo de cada cambio y se ramifiquen para experimentar sin afectar al código principal. Nuestra chuleta de comandos de Git cubre los comandos esenciales en 10 categorías, desde la configuración inicial y la preparación hasta flujos de trabajo avanzados como bisect y worktrees.
Cómo funciona nuestra chuleta de comandos de Git
- Busca o explora: escribe cualquier palabra clave en el cuadro de búsqueda para filtrar al instante los comandos por nombre, descripción, opciones o ejemplos. O usa las píldoras de categoría para explorar los comandos por área de trabajo: Preparación, Ramas, Deshacer cambios y más.
- Lee y expande: cada tarjeta muestra el comando, una descripción en lenguaje sencillo y un ejemplo real. Haz clic en «Show flags» para expandir las opciones disponibles de ese comando con explicaciones de cada una.
- Copia y usa: haz clic en el icono de copiar junto a cualquier comando o ejemplo para copiarlo al portapapeles al instante. Todo el procesamiento se ejecuta localmente en tu navegador: no se envía ningún dato a ningún servidor.
Categorías de comandos de Git
- Configuración inicial: configura tu identidad, editor y alias con git config; estos ajustes se aplican globalmente a todos los repositorios de tu máquina.
- Preparación y capturas: el flujo de trabajo central: usa git add, git commit y git diff para preparar y registrar cambios en tu repositorio.
- Ramas y fusiones: usa git branch, git switch, git merge y git rebase para gestionar líneas de desarrollo paralelas e integrar cambios.
- Deshacer cambios: usa git restore, git revert y git reset para deshacer cambios, cada uno con distintos niveles de permanencia y seguridad.
git reset vs git revert vs git restore
Estos tres comandos suelen confundirse. git restore descarta los cambios no confirmados en tu directorio de trabajo o quita archivos de la preparación: solo afecta a tu árbol de trabajo local y es la opción más segura. git revert crea un nuevo commit que deshace un commit anterior: es seguro usarlo en ramas compartidas porque conserva el historial. git reset mueve el puntero HEAD y, opcionalmente, modifica el índice y el árbol de trabajo: usa --soft para mantener los cambios preparados, --mixed para quitarlos de la preparación o --hard para descartarlos por completo. Nunca uses git reset --hard en commits que ya se hayan enviado a un remoto compartido.
Preguntas frecuentes
Una chuleta de comandos de Git es una guía de referencia rápida que lista los comandos de Git más importantes con descripciones, opciones y ejemplos. Nuestra chuleta interactiva de comandos de Git te permite buscar en todos los comandos y copiar cualquier comando al instante.
git fetch descarga los cambios del remoto sin integrarlos. git pull es git fetch + git merge (o rebase). Usa fetch para revisar los cambios primero y pull para actualizar de inmediato.
Usa git reset --soft HEAD~1 para deshacer el commit manteniendo los cambios preparados. Usa --mixed para quitarlos de la preparación. Usa --hard solo para descartar los cambios de forma permanente.
Sí. Nuestra chuleta de comandos de Git se ejecuta por completo en tu navegador sin peticiones al servidor. Tus búsquedas nunca salen de tu dispositivo.
¡Sí! 100 % gratis, sin registro, sin cuenta y sin límites de uso.