Ramas de funcionalidades y hotfixes
Implemente estrategias eficaces para trabajar con ramas de funcionalidades y aprenda a aplicar rápidamente hotfixes en entornos de producción.
Ramas de funcionalidades y hotfixes es una lección gratuita de Git Advanced: Monorepo, Submodules & Workflows en CoddyKit. Esta es la lección 3 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Git Advanced: Monorepo, Submodules & Workflows, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Git Advanced: Monorepo, Submodules & Workflows incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
Why Feature Branches?
When working on new features or major changes, it's best to keep them separate from your main codebase. This is where feature branching comes in!
It allows developers to work on new functionality in isolation without affecting the stable version of the project. This prevents half-finished work from breaking the main branch.
Creating a Feature Branch
To start a new feature, you'll create a new branch from your main development line, often main or develop. This creates a separate timeline for your work.
Use the git checkout -b command to create a new branch and switch to it in one go.
git checkout -b my-new-featureWorking in Isolation
Once on your feature branch, you can make changes, add files, and commit as usual. Your commits will only exist on this branch, not on main.
It's good practice to push your feature branch to the remote repository regularly, especially if you're collaborating or want a backup.
git add .
git commit -m "Implement initial feature UI"
git push origin my-new-featureMerging a Feature Branch
After your feature is complete, reviewed, and tested, it's time to integrate it back into the main development branch. You'll switch to the target branch (e.g., main) and then merge your feature branch.
Git will combine the changes. Often, a merge commit is created, showing exactly when the feature was integrated.
git checkout main
git merge my-new-featureCleaning Up Feature Branches
Once a feature branch has been merged and is no longer needed, it's good practice to delete it. This keeps your list of branches tidy and easier to manage.
Remember to delete both the local and remote versions of the branch.
git branch -d my-new-feature
git push origin --delete my-new-featureUrgent Fixes: Hotfixes
Sometimes, critical bugs appear in the production environment that need immediate attention. These are called hotfixes.
A hotfix workflow allows you to quickly fix the issue and deploy it, minimizing downtime, without waiting for the next planned feature release.
Branching for a Hotfix
Unlike feature branches, hotfixes are typically branched directly from the production-ready branch (e.g., main or master). This ensures you're fixing the exact code currently in production.
You create a new branch specifically for the hotfix, often named with a prefix like hotfix/.
git checkout main
git checkout -b hotfix/critical-bug-2023-01Fix, Commit, Test
On your hotfix branch, you'll apply the necessary changes to resolve the bug. Keep the fix as small and focused as possible to reduce risk.
After making changes, commit them with a clear message and thoroughly test the fix to ensure it solves the problem without introducing new ones.
git add .
git commit -m "HOTFIX: Fix login issue on production"
// Run tests hereDeploying & Integrating Hotfixes
Once the hotfix is verified, it needs to be merged back into the production branch (e.g., main) and immediately deployed.
Crucially, the hotfix also needs to be merged into your long-running development branch (e.g., develop) to prevent the bug from reappearing in future releases.
git checkout main
git merge hotfix/critical-bug-2023-01
git push origin main
git checkout develop
git merge hotfix/critical-bug-2023-01
git push origin developFeature vs. Hotfix Check
You've learned about feature branching and hotfixes. Let's test your understanding!
Summary: Branching for Success
In this lesson, you mastered two essential Git branching strategies:
- Feature Branching: Ideal for developing new features in isolation, ensuring a stable main codebase. You learned to create, work on, merge, and delete feature branches.
- Hotfixes: Crucial for quickly addressing critical bugs in production. You saw how to create hotfix branches from production, apply fixes, and merge them back to both production and development lines.
These techniques are vital for managing complex projects and maintaining a smooth development workflow with your team.
Preguntas frecuentes
¿La lección «Ramas de funcionalidades y hotfixes» es gratis?
Sí — el texto completo de «Ramas de funcionalidades y hotfixes» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Git Advanced: Monorepo, Submodules & Workflows, actualiza a CoddyKit PRO. El curso de Git Advanced: Monorepo, Submodules & Workflows incluye 4 lecciones en total.
¿Qué aprenderé en «Ramas de funcionalidades y hotfixes»?
Implemente estrategias eficaces para trabajar con ramas de funcionalidades y aprenda a aplicar rápidamente hotfixes en entornos de producción. Practicas Git Advanced: Monorepo, Submodules & Workflows con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Git Advanced: Monorepo, Submodules & Workflows?
No se requiere experiencia previa. Git Advanced: Monorepo, Submodules & Workflows en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 3 de 4.
¿Cuánto tiempo toma la lección «Ramas de funcionalidades y hotfixes»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Git Advanced: Monorepo, Submodules & Workflows?
Sí. Cada lección de Git Advanced: Monorepo, Submodules & Workflows incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Git Flow frente a GitHub Flow
- GitLab Flow y gestión de versiones
- Ramas de funcionalidades y hotfixes
- Desarrollo basado en trunk e integración continua