Gitflow Workflow
ServITech Backend API uses Gitflow to organize development and maintain a clean, structured approach to version control. This guide explains the branch strategy and workflow used in the project.Branch Strategy
Gitflow uses two main branches and several supporting branch types:Main Branches
main— Production-ready code. All releases are deployed from this branch.dev— Integration branch for ongoing development. All features are merged here first.
Supporting Branches
Gitflow uses the following supporting branch types:feature/*— For developing new featuresrelease/*— For preparing new production releasesbugfix/*— For fixing bugs found during developmenthotfix/*— For critical fixes in production
All supporting branches are temporary and should be deleted after merging.
Getting Started with Gitflow
Initialize Gitflow
Run the following command to configure Gitflow with default branch names:This automatically configures
main and dev as your primary branches.Working with Features
Starting a New Feature
When you start working on a new feature, create a feature branch fromdev:
feature/nombre-de-tu-feature and switches to it.
Example:
Working on Your Feature
Make your changes, commit them regularly:Finishing a Feature
When your feature is complete and tested:- Merge your feature branch into
dev - Delete the feature branch
- Switch you back to
dev
Creating Releases
Starting a Release
Whendev contains all features for a release:
release/v1.0.0 branch where you can:
- Update version numbers
- Fix last-minute bugs
- Update documentation
- Prepare release notes
Finishing a Release
When the release is ready for production:- Merge the release into
main - Tag the release with the version number
- Merge the release back into
dev - Delete the release branch
You’ll be prompted to enter a tag message. Include release notes and changelog information.
Handling Hotfixes
When to Use Hotfixes
Use hotfixes for critical bugs in production that can’t wait for the next release cycle.Creating a Hotfix
main.
Finishing a Hotfix
- Merge the hotfix into
main - Tag the hotfix version
- Merge the hotfix into
dev - Delete the hotfix branch
Bugfixes During Development
For bugs found during development (not in production):dev like features.
Best Practices
Branch Naming
- Use descriptive, lowercase names
- Separate words with hyphens
- Keep names concise but meaningful
Commit Messages
- Write clear, descriptive commit messages
- Focus on “why” rather than “what”
- Use present tense (“Add” not “Added”)
- Keep the first line under 50 characters
Before Merging
Contributing Workflow
When contributing to ServITech:All pull requests should target the
dev branch, never main directly.Common Commands Reference
Troubleshooting
Feature Branch Not Deleted
If a feature branch wasn’t deleted automatically:Merge Conflicts
If you encounter merge conflicts when finishing a feature:- Gitflow will pause and show you the conflicts
- Resolve conflicts in the affected files
- Stage the resolved files:
git add . - Continue:
git flow feature finish <name>
Accidentally Started on Wrong Branch
If you started a feature from the wrong branch:Next Steps
- Learn about API Versioning strategies
- Review Security Best Practices
- Check the API Documentation