This document provides detailed instructions for using Git Flow with the ts-json-rpc project using standard git commands only.
- Git installed and configured
- Access to the repository
Ensure you have both main branches:
# Clone the repository
git clone <repository-url>
cd ts-json-rpc
# Create develop branch if it doesn't exist
git checkout -b develop
git push -u origin develop
# Switch back to main
git checkout mainmain: Production-ready code only. Tagged releases.develop: Integration branch. Latest development changes.
feature/*: New features and enhancementsrelease/*: Release preparation and versioninghotfix/*: Critical production fixes
git checkout develop
git pull origin develop
git checkout -b feature/add-websocket-transport# Make your changes
npm run build
npm test
npm run lint
# Commit regularly
git add .
git commit -m "feat(transport): add WebSocket transport implementation"
# Push feature branch for backup/collaboration
git push -u origin feature/add-websocket-transport# Update develop branch
git checkout develop
git pull origin develop
# Merge feature with no-fast-forward to preserve branch history
git merge --no-ff feature/add-websocket-transport
# Push changes
git push origin develop
# Clean up local branch
git branch -d feature/add-websocket-transport
# Clean up remote branch
git push origin --delete feature/add-websocket-transportgit checkout develop
git pull origin develop
git checkout -b release/0.2.0# Update package.json versions
npm version 0.2.0 --no-git-tag-version
# Update CHANGELOG.md
npm run changelog
# Final testing
npm run build
npm test
npm run lint
# Commit release changes
git add .
git commit -m "chore(release): prepare version 0.2.0"
# Push release branch
git push -u origin release/0.2.0# Merge to main
git checkout main
git pull origin main
git merge --no-ff release/0.2.0
# Tag the release
git tag -a v0.2.0 -m "Release version 0.2.0"
# Push main and tags
git push origin main --tags
# Merge back to develop
git checkout develop
git pull origin develop
git merge --no-ff release/0.2.0
git push origin develop
# Clean up release branch
git branch -d release/0.2.0
git push origin --delete release/0.2.0git checkout main
git pull origin main
git checkout -b hotfix/critical-security-fix# Make minimal fix
# Add regression test
# Update version (patch increment)
npm run build
npm test
npm run lint
git add .
git commit -m "fix(security): resolve critical vulnerability"
# Push hotfix branch
git push -u origin hotfix/critical-security-fix# Merge to main
git checkout main
git pull origin main
git merge --no-ff hotfix/critical-security-fix
# Tag the hotfix
git tag -a v0.1.1 -m "Hotfix version 0.1.1"
# Push main and tags
git push origin main --tags
# Merge to develop
git checkout develop
git pull origin develop
git merge --no-ff hotfix/critical-security-fix
git push origin develop
# Clean up hotfix branch
git branch -d hotfix/critical-security-fix
git push origin --delete hotfix/critical-security-fixAdd to your ~/.gitconfig for convenience:
[alias]
# Feature workflow
feature-start = "!f() { git checkout develop && git pull origin develop && git checkout -b feature/$1; }; f"
feature-finish = "!f() { git checkout develop && git pull origin develop && git merge --no-ff feature/$1 && git push origin develop && git branch -d feature/$1 && git push origin --delete feature/$1; }; f"
# Release workflow
release-start = "!f() { git checkout develop && git pull origin develop && git checkout -b release/$1; }; f"
release-finish = "!f() { git checkout main && git pull origin main && git merge --no-ff release/$1 && git tag -a v$1 -m \"Release version $1\" && git push origin main --tags && git checkout develop && git pull origin develop && git merge --no-ff release/$1 && git push origin develop && git branch -d release/$1 && git push origin --delete release/$1; }; f"
# Hotfix workflow
hotfix-start = "!f() { git checkout main && git pull origin main && git checkout -b hotfix/$1; }; f"
hotfix-finish = "!f() { git checkout main && git pull origin main && git merge --no-ff hotfix/$1 && git tag -a v$2 -m \"Hotfix version $2\" && git push origin main --tags && git checkout develop && git pull origin develop && git merge --no-ff hotfix/$1 && git push origin develop && git branch -d hotfix/$1 && git push origin --delete hotfix/$1; }; f"Usage examples:
git feature-start websocket-transport
git feature-finish websocket-transport
git release-start 0.2.0
git release-finish 0.2.0
git hotfix-start critical-fix
git hotfix-finish critical-fix 0.1.1Configure on GitHub/GitLab:
main branch:
- Require pull request reviews
- Require status checks (CI/CD)
- Require up-to-date branches
- Include administrators
develop branch:
- Require pull request reviews
- Require status checks (CI/CD)
- Allow force pushes (for maintainers)
feature/websocket-transportfeature/batch-request-optimizationfeature/custom-error-typesfeature/typescript-5-support
release/0.1.0(initial)release/0.2.0(minor)release/0.1.1(patch)
hotfix/security-vulnerabilityhotfix/memory-leak-fixhotfix/critical-error-handling
- Keep features small and focused
- Regularly rebase on develop to avoid conflicts:
git checkout feature/my-feature git rebase develop
- Write comprehensive tests
- Update documentation
- Use conventional commit messages
- No new features, only bug fixes
- Update version numbers consistently
- Generate/update CHANGELOG.md
- Thorough testing before merge
- Tag with semantic version
- Minimal changes only
- Include regression tests
- Fast-track testing
- Immediate deployment ready
- Merge to both main and develop
"Branch already exists"
git branch -D feature/branch-name
git checkout develop
git checkout -b feature/branch-name"Merge conflicts during merge"
# During merge, if conflicts occur:
git status # See conflicted files
# Edit files to resolve conflicts
git add .
git commit -m "resolve merge conflicts""Accidentally committed to wrong branch"
# Move commits to correct branch
git checkout correct-branch
git cherry-pick <commit-hash>
git checkout wrong-branch
git reset --hard HEAD~1 # Remove last commitClean up abandoned branches:
# Local cleanup
git branch -D feature/abandoned-feature
# Remote cleanup
git push origin --delete feature/abandoned-featureSync with remote:
# Fetch all remote branches
git fetch --all
# See all branches
git branch -a
# Clean up local references to deleted remote branches
git remote prune originReset branch to match remote:
git checkout main
git reset --hard origin/main- Start from
develop - Create
feature/branch - Work and commit regularly
- Push feature branch for backup
- Merge to
developwhen complete - Clean up feature branch
- Create
release/fromdevelop - Prepare release (versions, changelog)
- Test thoroughly
- Merge to
mainand tag - Merge back to
develop - Clean up release branch
- Create
hotfix/frommain - Fix issue quickly
- Test fix
- Merge to
mainand tag - Merge to
develop - Clean up hotfix branch