--- name: git-workflow description: Manage source control effectively with Git including branching strategies, commit conventions, merge conflict resolution, rebasing, and collaboration workflows like GitHub Flow or GitFlow. Use when managing feature branches, creating meaningful commits, resolving merge conflicts, rebasing branches, squashing commits, using interactive rebase, implementing branch naming conventions, following commit message standards, managing pull requests, or collaborating in team environments. --- # Git Workflow - Professional Version Control ## When to use this skill - Managing feature branches and branch strategies - Creating clear, meaningful commit messages - Resolving merge conflicts effectively - Rebasing branches to maintain clean history - Squashing commits before merging - Using interactive rebase to clean up history - Implementing branch naming conventions - Following commit message standards (Conventional Commits) - Managing pull requests and code reviews - Collaborating in team Git workflows - Recovering from Git mistakes (reset, revert, reflog) - Managing release branches and hotfixes ## When to use this skill - Managing code changes, collaborating with teams, creating branches, handling conflicts, and maintaining clean git history. - When working on related tasks or features - During development that requires this expertise **Use when**: Managing code changes, collaborating with teams, creating branches, handling conflicts, and maintaining clean git history. ## Core Principles 1. **Commit Often, Push When Stable** - Small, focused commits are easier to review and revert 2. **Main Branch is Sacred** - Always deployable, never commit directly 3. **Clear History Tells a Story** - Future developers read commit messages to understand why 4. **Review Before Sharing** - Check `git diff` before committing ## Essential Commands ### Starting Work ```bash # Update local repository git fetch origin git pull origin main # Create feature branch git checkout -b feature/user-authentication # Or: git switch -c feature/user-authentication # Branch naming conventions: # feature/description - new feature # fix/description - bug fix # refactor/description - code improvement # docs/description - documentation ``` ### Making Changes ```bash # Check what changed git status # Overview git diff # Unstaged changes git diff --staged # Staged changes git diff main...HEAD # All changes since branching # Stage changes git add path/to/file # Specific file git add path/to/directory # Entire directory git add -p # Interactive staging (recommended!) # Commit with good message git commit -m "feat: add user authentication endpoint - Implement JWT token generation - Add password hashing with bcrypt - Create middleware for auth verification Closes #123" ``` ### Commit Message Format **Use Conventional Commits:** ``` ():