Git Cheatsheet
Guía de referencia rápida para comandos esenciales de Git. Cheatsheet buscable cubriendo branches, commits, merges y más.
Flujo de trabajo en equipo
En entornos profesionales, los equipos suelen seguir una estrategia de ramificación donde cada tarea tiene su propia rama. Esto aísla las características y evita que el código sin terminar rompa la aplicación principal.
Consejos profesionales: Siempre busque commits pequeños y atómicos. Antes de fusionar su trabajo, use 'git fetch' y luego 'git rebase origin/dev' (o main) para asegurarse de que su código sea compatible con la última versión. Finalmente, use 'git push -f' en su rama de características para actualizar el remoto con su historial rebasado.
Configuración
Establecer la configuración global
Configura su identidad en todos los repositorios de su sistema.
Comenzar
Crear un repositorio git
Inicializa un nuevo repositorio Git en el directorio actual.
Clonar un repositorio git existente
Copia un repositorio Git existente desde un servidor remoto.
Commit
Confirmar todos los cambios rastreados
Organiza y confirma todos los archivos rastreados modificados en un comando.
Agregar nuevas modificaciones al último commit
Actualiza el último commit con cambios actuales y opcionalmente cambia el mensaje.
Ramificación
Crear una nueva rama
Crea una nueva rama en el puntero actual.
Cambiar a una rama
Cambia el HEAD a la rama especificada.
Fusionar una rama en la rama actual
Combina el historial de otra rama en la actual.
Crear y cambiar a una rama
La forma más común de comenzar a trabajar en una nueva característica.
Sincronización
Obtener actualizaciones del remoto
Descarga cambios remotos sin fusionarlos.
Obtener últimos cambios
Obtiene cambios e intenta fusionarlos inmediatamente.
Rebasar rama actual en main
Reproduce sus commits sobre la última rama main.
Enviar cambios (Forzado)
Actualiza forzosamente la rama remota con su historial local. ¡Use solo en ramas privadas!
Comandos útiles
Verificar estado
Ver qué archivos están modificados, organizados o sin rastrear.
Guardar cambios temporalmente
Oculta temporalmente los cambios para trabajar en otra cosa.
Ver historial
Visualiza el historial de commits en todas las ramas.
Cómo usar esta Git Cheatsheet
- Browse the cheatsheet to find the Git command you need.
- Commands are organized by category: Configuration, Get Started, Commit, Branching, Syncing, and Useful Commands.
- Click the copy button next to any command to copy it to your clipboard.
- Paste the command into your terminal and modify the placeholder values as needed.
Advanced Rebasing
Rebasing is often preferred over merging to maintain a clean, linear project history. Instead of creating a 'merge commit', it repositions your commits at the end of the target branch.
Tip
Remember: Never rebase a public branch that others are working on, as it rewrites history and can cause significant conflicts for your peers.
Key Features
- Essential Git commands organized by workflow category
- One-click copy for every command
- Clear descriptions explaining what each command does
- Covers configuration, branching, syncing, and more
- Team workflow guidance with professional tips
- Rebasing best practices and safety warnings
- Works offline once loaded in your browser
Common Use Cases
- Quick reference while working in the terminal
- Onboarding new developers to Git workflows
- Reviewing branching and merging strategies
- Learning Git commands for the first time
- Refreshing memory on less frequently used commands
- Setting up Git configuration on a new machine
Preguntas Frecuentes
What is the difference between git merge and git rebase?
Git merge creates a new merge commit that combines two branches, preserving the full history. Git rebase replays your commits on top of the target branch, creating a linear history. Rebase produces a cleaner log but should never be used on shared public branches.
When should I use git stash?
Use git stash when you need to switch branches but have uncommitted changes you are not ready to commit. Stash saves your working directory state temporarily. You can restore it later with 'git stash pop' on any branch.
Is it safe to use git push --force?
Force pushing is safe only on branches that you alone work on, such as personal feature branches. Never force push to shared branches like main or develop, as it rewrites remote history and can cause other team members to lose their work.