| name | git-workflow |
| description | Git workflows, branching strategies, and DevOps practices |
| homepage | https://git-scm.com/doc |
| metadata | {"emoji":"🔀","version":"1.0.0","author":"Gourav Shah","license":"MIT","requires":{"bins":["git"]},"tags":["git","version-control","devops","workflow"]} |
Git Workflow
Git operations and DevOps best practices.
When to Use This Skill
Use this skill when:
- Managing code changes
- Creating pull requests
- Handling releases
- Resolving conflicts
- Debugging with git history
Daily Operations
Status & Info
git status
git status -s
git branch --show-current
git log --oneline -10
git log --oneline --since="midnight"
Sync with Remote
git fetch origin
git pull --rebase
git pull origin main
Commit Changes
git add file1.txt file2.txt
git add -A
git add -p
git commit -m "feat: add user authentication"
git commit --amend
git commit --amend --no-edit
Branch Management
Create & Switch
git checkout -b feature/new-feature
git switch -c feature/new-feature
git checkout main
git switch main
git checkout -b hotfix/bug-123 origin/main
List Branches
git branch
git branch -r
git branch -a
git branch -v
Delete Branches
git branch -d feature/old-feature
git branch -D feature/abandoned
git push origin --delete feature/old-feature
git fetch --prune
Pull Requests (GitHub CLI)
Create PR
git push -u origin feature/my-feature
gh pr create --title "Add feature X" --body "Description here"
gh pr create --fill
gh pr create --draft
Review PRs
gh pr list
gh pr view 123
gh pr checkout 123
gh pr diff 123
Merge PRs
gh pr merge 123
gh pr merge 123 --squash
gh pr merge 123 --rebase
gh pr merge 123 --delete-branch
Hotfix Workflow
git checkout main
git pull origin main
git checkout -b hotfix/critical-bug-123
git add .
git commit -m "fix: resolve critical bug #123"
git push -u origin hotfix/critical-bug-123
gh pr create --title "Hotfix: Critical bug #123" --base main
git checkout main
git pull origin main
git tag -a v1.2.1 -m "Hotfix release v1.2.1"
git push origin v1.2.1
Release Management
Tagging
git tag -a v1.2.0 -m "Release v1.2.0"
git tag -l
git tag -l "v1.*"
git push origin v1.2.0
git push origin --tags
git tag -d v1.2.0
git push origin --delete v1.2.0
Changelog from Commits
git log $(git describe --tags --abbrev=0)..HEAD --oneline
git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"- %s"
Debugging with Git
Find Who Changed What
git blame file.txt
git blame -L 10,20 file.txt
git blame -w file.txt
Find When Bug Introduced
git bisect start
git bisect bad HEAD
git bisect good v1.0.0
git bisect good
git bisect reset
Search History
git log --grep="bug fix"
git log -S "function_name" --oneline
git log -G "regex_pattern"
git log -p --grep="feature"
Undo Operations
Unstage Files
git restore --staged file.txt
git reset HEAD file.txt
Discard Changes
git restore file.txt
git restore .
git checkout -- file.txt
Reset Commits
git reset --soft HEAD~1
git reset HEAD~1
git reset --hard HEAD~1
Revert (Safe for Shared History)
git revert HEAD
git revert abc1234
git revert --no-commit abc1234
Stashing
git stash
git stash push -m "WIP: feature X"
git stash list
git stash pop
git stash apply stash@{1}
git stash drop stash@{0}
Merge & Rebase
Merge
git merge feature/new-feature
git merge --no-ff feature/new-feature
git merge --abort
Rebase
git rebase main
git rebase -i HEAD~3
git rebase --continue
git rebase --abort
Conflict Resolution
git status
git add resolved-file.txt
git rebase --continue
Configuration
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.st status
git config --global alias.lg "log --oneline --graph --all"
Quick Reference
git fetch --all && git pull --rebase
git checkout -b feature/X && [make changes] && git add . && git commit -m "feat: X" && git push -u origin feature/X && gh pr create
git add . && git commit --amend --no-edit && git push --force-with-lease
git branch --merged | grep -v "main\|master" | xargs git branch -d
Related Skills
- terraform-workflow: For IaC version control
- k8s-deploy: For deployment workflows
- incident-response: For hotfix procedures