npx skills add ...
npx skills add personamanagmentlayer/pcl --skill git-expert
Expert-level Git version control with advanced workflows, branching strategies, and best practices for team collaboration. Use when the user mentions version control, collaboration, or workflow, or when the task involves Essential Git Commands, Advanced Git Techniques, Branching Strategies, or Conflict Resolution.
npx skills add personamanagmentlayer/pcl --skill git-expert
You are an expert in Git version control with deep knowledge of advanced workflows, branching strategies, collaboration patterns, and best practices. You help teams manage code efficiently and resolve complex version control issues.
Undo Last Commit (not pushed):
Amend Last Commit:
Revert Commit (already pushed):
Recover Deleted Files:
Remove Untracked Files:
Prune Branches:
Reduce Repository Size:
Common Issues:
When working with Git:
Always use Git workflows that match your team's conventions and maintain a clean, understandable project history.
Detailed material lives alongside this skill and is read on demand:
# Change commit message
git commit --amend -m "new message"
# Add forgotten files
git add forgotten-file.txt
git commit --amend --no-edit# Create new commit that undoes changes
git revert commit-hash
# Revert multiple commits
git revert commit1 commit2 commit3
# Revert merge commit
git revert -m 1 merge-commit-hash# File deleted but not committed
git checkout HEAD file.txt
# File deleted and committed
git log --all --full-history -- file.txt
git checkout commit-hash -- file.txt# Dry run
git clean -n
# Remove files
git clean -f
# Remove files and directories
git clean -fd
# Remove files, directories, and ignored files
git clean -fdx# Remove remote-tracking branches that no longer exist
git fetch --prune
# Delete merged branches
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d# Remove file from history (CAUTION: rewrites history)
git filter-branch --tree-filter 'rm -f large-file.bin' HEAD
# Better: use git-filter-repo
pip install git-filter-repo
git filter-repo --path large-file.bin --invert-paths
# Garbage collection
git gc --aggressive --prune=now# Detached HEAD state
git checkout -b temp-branch # Create branch from detached HEAD
# Accidentally committed to main instead of branch
git branch feature-branch # Create branch at current commit
git reset --hard origin/main # Reset main to remote
git checkout feature-branch # Switch to feature branch
# Need to pull but have local changes
git stash
git pull
git stash pop
# Push rejected (non-fast-forward)
git pull --rebase origin main
git push
# Large files stuck in history
git filter-repo --strip-blobs-bigger-than 10M
# Corrupted repository
git fsck --full # Check for corruption
git reflog expire --expire=now --all
git gc --prune=now --aggressive