Common Git workflows: feature branches, releases, and collaboration
Start new feature development
git checkout -b feature/new-feature
Keep feature branch up to date
git rebase origin/main
Push feature branch to remote
git push -u origin feature/new-feature
Create PR on GitHub/GitLab
gh pr create --title "Add new feature"
Delete merged feature branch
git branch -d feature/new-feature
Set up Git Flow in repository
git flow init
Create feature branch
git flow feature start feature-name
Complete and merge feature
git flow feature finish feature-name
Create release branch
git flow release start 1.0.0
Complete release
git flow release finish 1.0.0
Create hotfix branch
git flow hotfix start hotfix-name
Complete hotfix
git flow hotfix finish hotfix-name
Create branch for small changes
git checkout -b fix/typo
For small, safe changes
git commit -m "Fix typo"
Merge changes within hours
git merge fix/typo
Run tests before merge
git push && # CI runs automatically
Branch for release preparation
git checkout -b release/v1.0.0
Update version numbers
npm version patch
Create release tag
git tag -a v1.0.0 -m "Release v1.0.0"
Push tags to remote
git push origin --tags
Merge release to main
git checkout main && git merge release/v1.0.0
Get latest changes
git fetch origin
Update local branch
git pull --rebase origin main
See what changed
git log --oneline origin/main..HEAD
Force push after rebase
git push --force-with-lease
See branch comparison
git status
Ask for code review
gh pr create --reviewer username
Fix review comments
git commit --amend
Push changes to PR
git push origin feature-branch
Approve pull request
gh pr review --approve
Merge approved PR
gh pr merge --squash
See conflict status
git status
Cancel merge operation
git merge --abort
Edit conflicted files
git mergetool
Complete merge after resolution
git commit
Skip merge commit
git merge --no-commit
Complete feature development workflow
# 1. Start new feature
git checkout main
git pull origin main
git checkout -b feature/user-authentication
# 2. Work on feature
git add .
git commit -m "Add user authentication system"
git push origin feature/user-authentication
# 3. Keep feature up to date
git fetch origin
git rebase origin/main
# 4. Create pull request
gh pr create --title "Add user authentication" --body "Implements user login/logout functionality"
# 5. After review and approval
gh pr merge --squash
# 6. Clean up
git checkout main
git pull origin main
git branch -d feature/user-authentication
git push origin --delete feature/user-authentication
Structured workflow for releases
# Initialize Git Flow
git flow init
# Feature development
git flow feature start login-system
# ... work on feature ...
git flow feature finish login-system
# Release preparation
git flow release start 1.2.0
# ... prepare release ...
git flow release finish 1.2.0
# Hotfix for production
git flow hotfix start security-patch
# ... fix issue ...
git flow hotfix finish security-patch
# Push all branches and tags
git push origin --all
git push origin --tags
Complete release process
# 1. Create release branch
git checkout main
git pull origin main
git checkout -b release/v2.1.0
# 2. Update version and changelog
npm version minor
# Edit CHANGELOG.md
# 3. Commit release changes
git add .
git commit -m "Prepare release v2.1.0"
# 4. Create release tag
git tag -a v2.1.0 -m "Release v2.1.0"
# 5. Merge to main and develop
git checkout main
git merge release/v2.1.0
git push origin main
git checkout develop
git merge release/v2.1.0
git push origin develop
# 6. Push tags
git push origin --tags
# 7. Clean up
git branch -d release/v2.1.0
# 8. Create GitHub release
gh release create v2.1.0 --title "Release v2.1.0" --notes "New features and bug fixes"
Team collaboration patterns
# 1. Start of day - sync with team
git checkout main
git pull origin main
# 2. Create feature branch
git checkout -b feature/team-feature
# 3. Work and commit frequently
git add .
git commit -m "Add feature component"
git push origin feature/team-feature
# 4. Keep branch updated
git fetch origin
git rebase origin/main
# 5. Resolve conflicts if any
git status
# Edit conflicted files
git add .
git rebase --continue
# 6. Force push after rebase (safely)
git push --force-with-lease origin feature/team-feature
# 7. Create PR and request review
gh pr create --title "Add team feature" --reviewer @team
# 8. Address review feedback
git commit --amend
git push --force-with-lease origin feature/team-feature
Quick fix for production issues
# 1. Create hotfix branch from main
git checkout main
git pull origin main
git checkout -b hotfix/critical-bug
# 2. Fix the issue
# ... make minimal changes ...
git add .
git commit -m "Fix critical security vulnerability"
# 3. Test the fix
npm test
npm run build
# 4. Merge to main and tag
git checkout main
git merge hotfix/critical-bug
git tag -a v1.0.1 -m "Hotfix v1.0.1"
# 5. Deploy immediately
git push origin main
git push origin --tags
# 6. Create hotfix release
gh release create v1.0.1 --title "Critical Security Fix" --notes "Immediate deployment required"
# 7. Merge to develop
git checkout develop
git merge hotfix/critical-bug
git push origin develop
# 8. Clean up
git branch -d hotfix/critical-bug
GitHub PR review workflow
# PR Review Process
## Before creating PR:
- [ ] Code follows style guidelines
- [ ] All tests pass
- [ ] No console.log statements
- [ ] Documentation updated
- [ ] Branch is up to date with main
## PR Description template:
```
## Changes
- Brief description of changes
## Testing
- [ ] Unit tests added/updated
- [ ] Manual testing completed
- [ ] Cross-browser testing done
## Screenshots (if UI changes)
- Before/after screenshots
## Checklist
- [ ] Self-review completed
- [ ] Code follows project standards
- [ ] Documentation updated
```
## Review commands:
```
# Request review
gh pr create --reviewer username1,username2
# Check review status
gh pr view --json reviewDecision
# Merge after approval
gh pr merge --squash
```
Keep feature branches short-lived (hours to days, not weeks)
Use descriptive branch names: feature/user-auth
, fix/login-bug
Write clear commit messages: feat: add user authentication
Always pull latest changes before starting new work
Use --force-with-lease
instead of --force
for safety