| name | git-log |
| description | Git version control management for code commits, push operations, branch management, and maintaining git history records. Use when managing git operations in software projects, including committing code changes, pushing to remote repositories, viewing git logs, creating branches, and resolving merge conflicts. |
Git Version Control Management Skill
This skill provides tools and workflows for managing git operations in software development projects. It supports code commits, push operations, branch management, and git history maintenance.
Quick Start
- Check git status: Review current changes before committing
- Stage changes: Add modified files to staging area
- Commit changes: Create commits with descriptive messages
- Push to remote: Upload commits to remote repository
- Review history: View git log to understand project history
Core Workflow
Committing Code Changes
When making code changes:
- Check current status:
git status
- Stage files:
git add <file> or git add .
- Review staged changes:
git diff --cached
- Commit with message:
git commit -m "Descriptive message"
- Push to remote:
git push origin <branch>
Branch Management
For feature development:
- Create new branch:
git checkout -b feature/new-feature
- Work on branch: Make commits on the feature branch
- Switch branches:
git checkout main or git checkout feature/new-feature
- Merge branches:
git merge feature/new-feature (when ready)
- Delete old branches:
git branch -d feature/old-feature
Git History Review
To understand project history:
- View commit history:
git log --oneline --graph --all
- Check specific commit:
git show <commit-hash>
- Compare branches:
git diff main..feature/new-feature
- View file history:
git log --follow -p <file-path>
Remote Repository Operations
For collaboration:
- Check remote:
git remote -v
- Fetch updates:
git fetch origin
- Pull changes:
git pull origin main
- Push changes:
git push origin <branch>
- Set upstream:
git push -u origin <branch> (first push)
Common Git Patterns
Standard Commit Workflow
git status
git add .
git commit -m "feat: add new feature"
git push origin main
Feature Branch Workflow
git checkout -b feature/new-feature
git add .
git commit -m "feat: implement new feature"
git push -u origin feature/new-feature
git checkout main
git pull origin main
git merge feature/new-feature
git push origin main
Git Log Analysis
git log --oneline --graph --all
git log -5 --stat
git log --grep="bugfix"
git log --since="2024-01-01" --until="2024-12-31"
Error Handling
Common Issues and Solutions
1. Commit Rejected (Non-Fast-Forward)
git pull origin main --rebase
git push origin main --force
2. Merge Conflicts
git add .
git commit -m "fix: resolve merge conflicts"
3. Accidental Commit
git reset --soft HEAD~1
git reset --hard HEAD~1
4. Wrong Branch Commits
git stash
git checkout correct-branch
git stash pop
Best Practices
Commit Messages
- Use conventional commit format:
type(scope): description
- Types: feat, fix, docs, style, refactor, test, chore
- Keep descriptions concise but descriptive
- Reference issues/tickets when applicable
Branch Strategy
main: Production-ready code
develop: Integration branch
feature/*: New features
bugfix/*: Bug fixes
release/*: Release preparation
Git Hygiene
- Commit frequently with logical changes
- Keep commits focused on single purpose
- Write descriptive commit messages
- Review changes before committing
- Keep repository clean and organized
Resources
- Git Cheat Sheet: See
references/git-cheatsheet.md for common commands
- Commit Examples: See
references/commit-examples.md for good commit messages
- Branch Examples: See
references/branch-examples.md for branch management patterns
- YouTube-SC Examples: See
examples/youtube-sc/ for project-specific git workflows
When to Use This Skill
Use this skill when:
- Committing code changes to version control
- Managing git branches for feature development
- Pushing code to remote repositories
- Reviewing git history and understanding changes
- Resolving git conflicts and issues
- Maintaining clean git history and project structure