git init Initialize a new git repository
git clone <url> Clone a remote repository
git config --global user.name "Name" Set your global username
git config --global user.email "email" Set your global email
git config --list Show all configuration settings
git remote add origin <url> Add a remote repository
git remote -v List remote repositories
git branch List local branches
git branch -a List all branches (local + remote)
git branch <name> Create a new branch
git branch -d <name> Delete a branch (safe)
git branch -D <name> Force delete a branch
git branch -m <old> <new> Rename a branch
git checkout <branch> Switch to a branch
git checkout -b <name> Create and switch to new branch
git switch <branch> Switch to a branch (modern)
git switch -c <name> Create and switch (modern)
git status Show working tree status
git add <file> Stage a specific file
git add . Stage all changes
git add -p Stage changes interactively (by hunk)
git commit -m "message" Commit staged changes with message
git commit -am "message" Stage tracked files and commit
git commit --amend Amend the last commit
git diff Show unstaged changes
git diff --staged Show staged changes
git diff <branch1> <branch2> Compare two branches
git push Push commits to remote
git push -u origin <branch> Push and set upstream branch
git push --force Force push (destructive!)
git pull Fetch and merge remote changes
git pull --rebase Fetch and rebase instead of merge
git fetch Download remote changes without merging
git fetch --prune Fetch and remove deleted remote branches
git push origin --delete <branch> Delete a remote branch
git stash Stash current changes
git stash push -m "message" Stash with a description
git stash list List all stashes
git stash pop Apply and remove latest stash
git stash apply Apply latest stash without removing
git stash drop Delete latest stash
git stash clear Delete all stashes
git log Show commit history
git log --oneline Show compact commit history
git log --graph --oneline Show commit graph
git log -n 5 Show last 5 commits
git log --author="name" Filter commits by author
git log -- <file> Show commits for a specific file
git blame <file> Show who changed each line
git show <commit> Show details of a commit
git merge <branch> Merge a branch into current
git merge --no-ff <branch> Merge with a merge commit (no fast-forward)
git merge --abort Abort a merge in progress
git rebase <branch> Rebase current branch onto another
git rebase --abort Abort a rebase in progress
git cherry-pick <commit> Apply a specific commit to current branch
git restore <file> Discard changes in working directory
git restore --staged <file> Unstage a file
git reset HEAD~1 Undo last commit, keep changes staged
git reset --hard HEAD~1 Undo last commit and discard changes
git revert <commit> Create a new commit that undoes a commit
git clean -fd Remove untracked files and directories
git reflog Show history of HEAD changes (recovery)
git tag List all tags
git tag <name> Create a lightweight tag
git tag -a <name> -m "msg" Create an annotated tag
git push --tags Push all tags to remote
git tag -d <name> Delete a local tag
Cheatsheet de comandos Git
Una referencia completa y buscable de los comandos git más útiles. Filtra por categoría (configuración, ramas, commits, remoto, stash, historial, fusión, deshacer, etiquetas) o busca por palabra clave. Copia cualquier comando con un clic.
Sobre este cheatsheet
Este cheatsheet de Git cubre las operaciones más comunes organizadas por categoría de flujo de trabajo. Perfecto como referencia rápida mientras programas.
- Más de 65 comandos git con descripciones
- Filtrar por categoría (Configuración, Ramas, Commits, Remoto, Stash, Historial, Fusión, Deshacer, Etiquetas)
- Búsqueda de texto completo en comandos y descripciones
- Copia al portapapeles con un clic
- Funciona sin conexión: todos los datos están en la página
Gratis. Sin registro. Tus datos permanecen en tu navegador. Anuncios mediante Google AdSense (con consentimiento).
Por Marco B. ·