Before committing your code, ensure:
-
Code compiles without errors
./gradlew clean build
-
All tests pass
./gradlew test -
Code follows formatting standards
- Check
.editorconfigsettings - Use consistent spacing (2 spaces, not tabs)
- Check
-
No sensitive data in commit
- No
.envfiles - No API keys or secrets
- No personal information
- No
-
Documentation is updated
feature/<feature-name> # New features
bugfix/<bug-description> # Bug fixes
hotfix/<urgent-fix> # Production hotfixes
refactor/<refactor-name> # Code refactoring
docs/<doc-update> # Documentation only
test/<test-addition> # Test additions
Examples:
git checkout -b feature/messaging-service
git checkout -b bugfix/user-registration-validation
git checkout -b docs/api-documentation-update[Phase X] Type: Brief description
- Detailed change 1
- Detailed change 2
- Detailed change 3
Refs: #issue-number (if applicable)
Feature:- New featureFix:- Bug fixRefactor:- Code refactoringDocs:- Documentation updateTest:- Test additions/updatesChore:- Build/config changes
Good Commit Messages:
[Phase 1] Feature: Implement JWT authentication service
- Added JwtService with token generation
- Implemented token validation and expiration
- Added refresh token support
- Configured RS256 signing algorithm
Refs: #12
[Phase 1] Fix: Resolve user registration validation error
- Fixed email validation regex
- Added phone number format validation
- Updated error messages for clarity
[Phase 2] Feature: Create Conversation and Message entities
- Added Conversation entity with JPA mappings
- Added Message entity with status tracking
- Created database migrations V2 and V3
- Implemented repositories for both entities
Bad Commit Messages:
Fixed stuff
Updated code
WIP
...
# Switch to main branch
git checkout main
# Pull latest changes
git pull origin main
# Create feature branch
git checkout -b feature/your-feature-name# Check status frequently
git status
# Add files to staging
git add <specific-files>
# OR add all changed files
git add .
# Commit with descriptive message
git commit -m "[Phase X] Type: Description"# Push your branch
git push origin feature/your-feature-name
# If feature is complete, create PR on GitHub
# Otherwise, continue working tomorrow# Ensure all tests pass
./gradlew test
# Merge main into your branch (if needed)
git checkout main
git pull origin main
git checkout feature/your-feature-name
git merge main
# Resolve any conflicts, then push
git push origin feature/your-feature-name
# Create Pull Request on GitHub
# Request code review
# Merge after approval.env
.env.local
*.key
*.pem
*.p12
*.jks
application-local.yml
secrets/
*.log
node_modules/
build/ (except gradle wrapper)
.idea/ (IDE settings)
# See what will be committed
git diff --cached
# Review changes file by file
git diff HEAD# Discard changes in working directory
git checkout -- <file>
# Unstage files
git reset HEAD <file>
# Undo last commit (keep changes)
git reset --soft HEAD~1
# Undo last commit (discard changes)
git reset --hard HEAD~1# List all branches
git branch -a
# Delete local branch
git branch -d feature/branch-name
# Delete remote branch
git push origin --delete feature/branch-name
# Rename current branch
git branch -m new-branch-name# View commit history
git log --oneline --graph --decorate
# View changes in specific commit
git show <commit-hash>
# View file history
git log -- <file-path># Save changes temporarily
git stash
# List stashes
git stash list
# Apply most recent stash
git stash pop
# Apply specific stash
git stash apply stash@{0}Before creating a PR:
- Branch is up to date with main
- All tests pass locally
- Code follows project conventions
- No merge conflicts
- Documentation is updated
- Commit messages are clear
- No debug code or comments left
[Phase X] Feature: Brief description
## Description
Brief description of changes
## Changes Made
- Change 1
- Change 2
- Change 3
## Testing
- [ ] Unit tests added/updated
- [ ] Integration tests pass
- [ ] Manual testing completed
## Screenshots (if applicable)
Add screenshots here
## Checklist
- [ ] Code follows style guidelines
- [ ] Documentation updated
- [ ] No breaking changes
- [ ] Tests pass# Pull latest changes
git pull origin main
# Open conflicted files
# Resolve conflicts manually
# Look for <<<<<<, ======, >>>>>>
# After resolving
git add <resolved-files>
git commit -m "Resolved merge conflicts"# Remove file from staging
git reset HEAD <file>
# Remove file from last commit
git rm --cached <file>
git commit --amend# Amend last commit message
git commit --amend -m "New message"- Git Documentation
- GitHub Guides
- Git Cheat Sheet
- Oh Shit, Git!?! - Fix common mistakes
Remember: Good git hygiene makes collaboration easier and keeps the project history clean! 🎉