Git Workflow Documentation: master / staging / development Branch Strategy
NOTE:
- Use id with your name to develop feature or merge pull requests, so we have track of who did what things.
Branch Structure
- master: Stable, production-ready code. Only tested and verified features reach here.
- Can only be merged to
masterbranch initally by Ankit. Later the access will be given to other people, so everyone understand the flow.
- Can only be merged to
- staging: Pre-production branch for testing merged features together before releasing to main.
- Can only be merge to
stagingbranch initally by Ankit. - Later the access will be given to other people, so everyone understand the flow.
- Can only be merge to
- development: Active integration branch for ongoing feature development.
- Pull request can be merged by any other developer, not who created the pull request.
- feature/*: Temporary branches for individual features, fixes, or improvements.
- Branch name should start with
featue/then your specific feature name
- Branch name should start with
Naming Guidelines
-
Branch names:
feature/login-page,fix/token-expiry,chore/update-deps
-
Commit messages:
-
Format:
<type>: <message>feat:for new featuresfix:for bug fixeschore:for minor tasks
-
-
Pull Requests:
- Clear title and description
- Link issues if applicable
- Add screenshots/logs if needed
- Share the path of the url in the UI where it can be tested
Best Practices
- Always branch from
development - Regularly sync your feature branch with
development - Keep pull requests focused and small
- Test locally and on staging before going to main
- Use
revertto undo features instead of rewriting shared history
Development Flow
-
Create a feature branch
git checkout development git pull origin development git checkout -b feature/feature-name -
Work on your feature
- Use meaningful commit messages (e.g.
feat: add user login,fix: resolve token bug). - Keep commits atomic and scoped.
- Use meaningful commit messages (e.g.
-
Create a Pull Request to
development-
PR title: Start with
feat:/fix:/chore:depending on the change- Example:
feat: add login API with JWT support
- Example:
-
PR description:
- What the feature does
- Relevant issue/ticket link
- Any test instructions or special notes
-
-
Merge to
developmentusing Squash and Merge- Squash keeps history clean by combining all commits into one.
- Ensure commit message is clear and concise.
- Make sure you select
Sqash and mergeand not the other 2 options.
-
Promote from
developmenttostaginggit checkout staging git pull origin staging git merge development --rebase git push origin staging- Make sure the merge happens with the
Rebase and mergeoption and notMerge and commitorSquash and merge
- Make sure the merge happens with the
-
Promote from
stagingtomastergit checkout master git pull origin master git merge staging --rebase git push origin master- Make sure the merge happens with the
Rebase and mergeoption and notMerge and commitorSquash and merge
- Make sure the merge happens with the
Reverting a Feature
If a feature causes issues after merging to either master or staging, we will follow this:
-
Find the commit hash of the squash merge from the
staginghistory. -
Revert the specific commit only in development branch:
git checkout development git revert <commit-hash> git push origin development- This creates a new commit that undoes the feature changes.
- The revert will flow forward when merged to staging/master using the pull request.
NOTE: Selective Revert Process
Consider this scenario:
- A feature is already merged to both
masterandstaging - New features have been added to the
developmentbranch after the merge - You need to revert only the problematic feature without affecting other new work
Follow these steps to create a targeted revert:
- Identify the specific feature causing issues
- Create a pull request containing only the revert commit
- Deploy the revert to
staging/masterindependently - Keep other development work separate until ready for deployment
This allows you to promote the revert first, without waiting for the other new changes in development.
🧱 Scenario
-
Your branch:
development -
Contains:
- ✅ A revert commit (say, commit hash:
abc123) - ✅ A new feature commit (you don’t want to promote to staging yet)
- ✅ A revert commit (say, commit hash:
You want to send only the revert to staging, not the new feature yet.
1. Create a new branch from staging
git checkout staging
git pull origin staging
git checkout -b revert-onlyThis ensures the revert will apply cleanly over the current staging branch.
2. Cherry-pick only the revert commit from development which we want to revert
git cherry-pick abc123- Replace
abc123with the hash of the revert commit. - This applies just the revert onto the
revert-onlybranch.
3. Push this branch and create a PR
git push origin revert-only-
Go to GitHub and open a PR from
revert-only→staging. -
Use a clear PR title like:
revert: remove Feature X due to issue #42 -
This will safely revert the feature without bringing in unrelated new work from
development.
✅ After the revert is merged
Later, when you’re ready to bring in the new features from development, you can do your usual:
git checkout staging
git pull origin staging
git merge development --rebaseIf you already cherry-picked the revert earlier, Git will detect it’s already applied and skip it — avoiding duplicates.
🔄 Optional Clean-Up
Once the revert is merged:
git branch -d revert-only # delete local branch
git push origin --delete revert-only # delete remote branch (optional)