Saltar al contenido
Aback Tools Logo

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.

Git Command Cheat Sheet

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.

Showing all 44 Git commandsClick any command to copy

Setup & Config

5 commands
git config --global user.name "[name]"

Set the name that will be attached to your commits and tags.

Example: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.

Example:git config --global user.email "[email protected]"
git config --global core.editor "[editor]"

Set the default text editor for commit messages.

Example:git config --global core.editor "code --wait"
git config --list

List all Git configuration settings currently in effect.

Example:git config --list
git config --global alias.[alias] "[command]"

Create a shortcut alias for a Git command.

Example:git config --global alias.st status

Getting Started

2 commands
git init

Initialize a new local Git repository in the current directory.

Example:git init
git clone [url]

Clone a remote repository into a new local directory.

Example:git clone https://github.com/user/repo.git

Staging & Snapshots

6 commands
git status

Show the working tree status - staged, unstaged, and untracked files.

Example:git status
git add [file]

Stage a file or directory for the next commit.

Example:git add src/index.ts
git commit -m "[message]"

Record staged changes to the repository with a commit message.

Example:git commit -m "feat: add user authentication"
git diff

Show unstaged changes between your working directory and the index.

Example:git diff
git rm [file]

Remove a file from the working tree and stage the deletion.

Example:git rm old-file.txt
git mv [old] [new]

Move or rename a file and stage the change.

Example:git mv old-name.ts new-name.ts

Branching & Merging

6 commands
git branch

List, create, or delete branches.

Example:git branch feature/login
git checkout [branch]

Switch to an existing branch or restore working tree files.

Example:git checkout main
git switch [branch]

Switch to a branch (modern replacement for git checkout for branch switching).

Example:git switch feature/login
git merge [branch]

Merge the specified branch into the current branch.

Example:git merge feature/login
git rebase [branch]

Reapply commits on top of another base branch.

Example:git rebase main
git cherry-pick [commit]

Apply the changes from a specific commit onto the current branch.

Example:git cherry-pick a1b2c3d

Sharing & Updating

4 commands
git remote add [name] [url]

Add a new remote repository connection.

Example:git remote add origin https://github.com/user/repo.git
git fetch [remote]

Download objects and refs from a remote without merging.

Example:git fetch origin
git pull [remote] [branch]

Fetch from a remote and integrate (merge or rebase) into the current branch.

Example:git pull origin main
git push [remote] [branch]

Upload local branch commits to the remote repository.

Example:git push origin main

Inspection & Comparison

4 commands
git log

Show the commit history for the current branch.

Example:git log --oneline --graph --all
git show [commit]

Show information about a commit, tag, or tree object.

Example:git show a1b2c3d
git blame [file]

Show what revision and author last modified each line of a file.

Example:git blame src/index.ts
git tag [name]

Create, list, or delete tags.

Example:git tag v1.0.0

Undoing Changes

4 commands
git restore [file]

Discard changes in the working directory (modern replacement for checkout --).

Example:git restore src/index.ts
git revert [commit]

Create a new commit that undoes the changes from a previous commit.

Example:git revert a1b2c3d
git reset [commit]

Reset the current HEAD to a specified state.

Example:git reset --soft HEAD~1
git clean

Remove untracked files from the working directory.

Example:git clean -fd

Stashing

5 commands
git stash

Temporarily save uncommitted changes to a stash stack.

Example:git stash
git stash pop

Apply the most recent stash and remove it from the stash stack.

Example:git stash pop
git stash list

List all stashed changesets.

Example:git stash list
git stash apply [stash]

Apply a stash without removing it from the stash stack.

Example:git stash apply stash@{2}
git stash drop [stash]

Remove a single stash entry from the stash stack.

Example:git stash drop stash@{0}

Rewriting History

3 commands
git commit --amend

Modify the most recent commit - change message or add staged changes.

Example:git commit --amend -m "fix: corrected typo in auth module"
git rebase -i [base]

Interactively rebase - reorder, squash, edit, or drop commits.

Example:git rebase -i HEAD~3
git reflog

Show a log of all HEAD movements - useful for recovering lost commits.

Example:git reflog

Advanced

5 commands
git bisect start

Use binary search to find the commit that introduced a bug.

Example:git bisect start git bisect bad git bisect good v1.0
git submodule add [url]

Add a Git repository as a submodule inside another repository.

Example:git submodule add https://github.com/user/lib.git libs/lib
git worktree add [path] [branch]

Check out a branch into a new working directory without cloning.

Example:git worktree add ../hotfix hotfix/urgent
git archive [branch]

Create a tar or zip archive of a tree from a branch or commit.

Example:git archive --format=zip HEAD > release.zip
git shortlog

Summarize git log output grouped by author.

Example: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

  1. 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.
  2. 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.
  3. 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.