Saltar a contenido

Git Commands

"Clase de la hoja"

########################################################################################################################################################################################################################################################## Copiar todos los comandos
########################################################################################################################################################################################################################################################## Generar PDF seleccionado/button

■/div titulada

Integral Git comandos y flujos de trabajo para el control de versiones en todas las plataformas.

Comandos básicos

Command Description
git init Initialize a new Git repository
git clone <url> Clone a repository from remote URL
git status Show working directory status
git add <file> Add file to staging area
git add . Add all files to staging area
git commit -m "message" Commit staged changes with message
git push Push commits to remote repository
git pull Pull changes from remote repository

Branching

Command Description
git branch List all branches
git branch <name> Create new branch
git checkout <branch> Switch to branch
git checkout -b <name> Create and switch to new branch
git merge <branch> Merge branch into current branch
git branch -d <name> Delete branch

Operaciones remotas

Command Description
git remote -v Show remote repositories
git remote add <name> <url> Add remote repository
git fetch Fetch changes from remote
git push origin <branch> Push branch to remote
git pull origin <branch> Pull branch from remote

Comandos Avanzados

Command Description
git log --oneline Show commit history in one line
git diff Show changes between commits
git reset --hard <commit> Reset to specific commit
git stash Temporarily save changes
git stash pop Apply stashed changes
git rebase <branch> Rebase current branch
git cherry-pick <commit> Apply specific commit
git tag <name> Create a tag

Corrientes de trabajo comunes

Flujo de trabajo de la subdivisión de valores

# Create and switch to feature branch
git checkout -b feature/new-feature

# Make changes and commit
git add .
git commit -m "Add new feature"

# Push to remote
git push origin feature/new-feature

# Merge back to main
git checkout main
git merge feature/new-feature
git branch -d feature/new-feature

Flujo de trabajo de Hotfix

# Create hotfix branch from main
git checkout main
git checkout -b hotfix/critical-bug

# Fix the bug and commit
git add .
git commit -m "Fix critical bug"

# Merge to main and develop
git checkout main
git merge hotfix/critical-bug
git checkout develop
git merge hotfix/critical-bug

# Clean up
git branch -d hotfix/critical-bug

Buenas prácticas

Enviar mensajes

  • Use el tenso presente ("Agregar característica" no "Agregar característica")
  • Mantenga la primera línea bajo 50 caracteres
  • Use el cuerpo para explicar qué y por qué, no cómo
  • Cuestiones de referencia y solicitudes de selección cuando corresponda

Estrategia de ejecución

  • Uso de nombres de rama descriptivos
  • Mantener las ramas centradas en las características individuales
  • Eliminar las ramas fusionadas
  • Sincronización regular con la rama principal

Repository Management

  • Use .gitignore_ para excluir archivos innecesarios
  • Mantener compromisos atómicos y enfocados
  • Escriba mensajes de compromiso significativos
  • Use etiquetas para versiones
  • Respaldos regulares a repositorios remotos