Install
openclaw skills install git-plusEnhanced Git with advanced workflows, Git hooks, CI/CD integration, monorepo support, Git LFS, and Git internals deep dive.
openclaw skills install git-plusEnhanced Git with advanced workflows, hooks, and CI/CD integration.
| Task | Command |
|---|---|
| Status | git status -sb |
| Log | git log --oneline -10 --graph |
| Diff | git diff --stat HEAD~5 |
| Stash | git stash push -m "description" |
| Rebase | git rebase -i HEAD~5 |
# Feature
git checkout -b feature/new-feature develop
git commit -m "feat: add new feature"
git checkout develop
git merge --no-ff feature/new-feature
# Release
git checkout -b release/1.0.0 develop
git commit -m "chore: bump version"
git checkout main
git merge --no-ff release/1.0.0
git tag -a v1.0.0 -m "Release 1.0.0"
# Hotfix
git checkout -b hotfix/urgent-fix main
git commit -m "fix: urgent issue"
git checkout main
git merge --no-ff hotfix/urgent-fix
# Short-lived feature branch
git checkout -b feature/short-lived
git commit -m "feat: quick change"
git push origin feature/short-lived
# Create PR, merge to main
# Direct commit (for small changes)
git checkout main
git pull origin main
git commit -m "feat: small change"
git push origin main
# Create branch
git checkout -b feature/my-feature
# Make changes
git add .
git commit -m "feat: add feature"
# Push and create PR
git push origin feature/my-feature
# Create PR via GitHub UI
# After review, merge via GitHub
#!/bin/bash
# .git/hooks/pre-commit
# Run linter
npm run lint
# Run tests
npm test
# Check for secrets
if grep -r "password\|secret\|api_key" --include="*.js" --include="*.ts" .; then
echo "Error: Potential secrets found"
exit 1
fi
#!/bin/bash
# .git/hooks/commit-msg
# Validate conventional commit format
commit_msg=$(cat "$1")
pattern="^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?: .{1,72}"
if ! echo "$commit_msg" | grep -qE "$pattern"; then
echo "Error: Invalid commit message format"
echo "Format: type(scope): description"
echo "Example: feat(auth): add login page"
exit 1
fi
#!/bin/bash
# .git/hooks/pre-push
# Run tests before push
npm test
# Check for force push
for ref in "$@"; do
if echo "$ref" | grep -qE "refs/heads/(main|master|develop)$"; then
read -p "Force push to protected branch? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
done
# Copy hooks to .git/hooks
cp hooks/* .git/hooks/
# Or use Husky (Node.js)
npx husky install
npx husky add .git/hooks/pre-commit "npm run lint"
# .github/workflows/ci.yml
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm test
- run: npm run lint
deploy:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm run build
- run: npm run deploy
# .gitlab-ci.yml
stages:
- test
- build
- deploy
test:
stage: test
script:
- npm ci
- npm test
- npm run lint
build:
stage: build
script:
- npm ci
- npm run build
artifacts:
paths:
- dist/
deploy:
stage: deploy
script:
- npm run deploy
only:
- main
# Add worktree for feature
git worktree add ../feature-branch feature/branch
# List worktrees
git worktree list
# Remove worktree
git worktree remove ../feature-branch
# Enable sparse checkout
git sparse-checkout init --cone
# Set directories
git sparse-checkout set packages/frontend packages/shared
# Update
git sparse-checkout disable
# Add submodule
git submodule add https://github.com/user/repo.git libs/repo
# Update submodules
git submodule update --init --recursive
# Clone with submodules
git clone --recurse-submodules https://github.com/user/repo.git
# View object type and size
git cat-file -t <sha>
git cat-file -s <sha>
# View object content
git cat-file -p <sha>
# List objects
git rev-list --objects --all
# View refs
git show-ref
# View reflog
git reflog
# Find branches containing commit
git branch --contains <sha>
# Create packfile
git gc
# Verify packfile
git verify-pack -v .git/objects/pack/*.idx
# View packfile statistics
git count-objects -v
# Rebase last 5 commits
git rebase -i HEAD~5
# Commands:
# p, pick = keep commit
# r, reword = keep commit, edit message
# e, edit = keep commit, amend
# s, squash = meld into previous commit
# f, fixup = like squash, discard this commit's message
# d, drop = remove commit
# Cherry-pick single commit
git cherry-pick <sha>
# Cherry-pick range
git cherry-pick <start-sha>..<end-sha>
# Cherry-pick without committing
git cherry-pick --no-commit <sha>
# Start bisect
git bisect start
git bisect bad
git bisect good v1.0.0
# Git checks out middle commit
# Test it, then mark as good or bad
git bisect good # or git bisect bad
# Reset
git bisect reset