agentleFS
ianallowayianalloway/openclaw-skills/git-helper/SKILL.md

git-helper

Skill4 starsChanged 5 months agoMITView on GitHub

Common git commands, workflows, and troubleshooting for everyday development

  • Deletes or force-pushes
  • Commits and pushes

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 6 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Follow conventional commits for clean history:

    line 38
  2. Distinctive:

    Always pull before starting new work

    line 283
  3. Distinctive:

    Commit early and often

    line 284
  4. Distinctive:

    Write meaningful commit messages

    line 285
  5. Distinctive:

    Use branches for features/fixes

    line 286
  6. Distinctive:

    Never force push to shared branches

    line 287

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Git Helper

Quick reference for common git operations, workflows, and fixes.

Daily Workflow

# Start your day - pull latest changes
git pull origin main

# Create feature branch
git checkout -b feature/my-new-feature

# Stage and commit changes
git add -A
git commit -m "feat: add new feature"

# Push to remote
git push origin feature/my-new-feature

Commit Message Convention

Follow conventional commits for clean history:

# Format: type(scope): description

git commit -m "feat: add user authentication"
git commit -m "fix: resolve login redirect bug"
git commit -m "docs: update API documentation"
git commit -m "style: format code with prettier"
git commit -m "refactor: simplify database queries"
git commit -m "test: add unit tests for auth module"
git commit -m "chore: update dependencies"

Undo Mistakes

# Undo last commit (keep changes staged)
git reset --soft HEAD~1

# Undo last commit (keep changes unstaged)
git reset HEAD~1

# Discard all local changes
git checkout -- .

# Discard changes to specific file
git checkout -- path/to/file

# Undo a pushed commit (creates new commit)
git revert HEAD

# Amend last commit message
git commit --amend -m "new message"

Branch Management

# List all branches
git branch -a

# Delete local branch
git branch -d branch-name

# Delete remote branch
git push origin --delete branch-name

# Rename current branch
git branch -m new-name

# Switch to previous branch
git checkout -

# Create branch from specific commit
git checkout -b new-branch abc1234

Stashing

# Stash current changes
git stash

# Stash with message
git stash push -m "work in progress on feature X"

# List stashes
git stash list

# Apply most recent stash
git stash pop

# Apply specific stash
git stash apply stash@{2}

# Drop a stash
git stash drop stash@{0}

Viewing History

# Pretty log
git log --oneline --graph --decorate -20

# Log with stats
git log --stat -5

# Search commits by message
git log --grep="bug fix"

# Show commits by author
git log --author="Ian"

# Show changes in commit
git show abc1234

# Blame a file (who changed what)
git blame path/to/file

Merging & Rebasing

# Merge branch into current
git merge feature-branch

# Rebase onto main (cleaner history)
git rebase main

# Interactive rebase (squash commits)
git rebase -i HEAD~3

# Abort a merge/rebase
git merge --abort
git rebase --abort

# Continue after resolving conflicts
git rebase --continue

Working with Remotes

# List remotes
git remote -v

# Add remote
git remote add upstream https://github.com/openclaw/openclaw.git

# Fetch from all remotes
git fetch --all

# Pull from upstream
git pull upstream main

# Push to different remote
git push upstream feature-branch

Cherry Pick

# Apply specific commit to current branch
git cherry-pick abc1234

# Cherry pick without committing
git cherry-pick -n abc1234

# Cherry pick range of commits
git cherry-pick abc1234..def5678

Clean Up

# Remove untracked files (dry run)
git clean -n

# Remove untracked files
git clean -f

# Remove untracked files and directories
git clean -fd

# Prune remote tracking branches
git remote prune origin

# Garbage collect
git gc

Diff & Compare

# Show unstaged changes
git diff

# Show staged changes
git diff --staged

# Compare branches
git diff main..feature-branch

# Compare with remote
git diff origin/main

# Show changed files only
git diff --name-only

Tags

# Create tag
git tag v1.0.0

# Create annotated tag
git tag -a v1.0.0 -m "Release version 1.0.0"

# Push tags
git push origin --tags

# Delete tag
git tag -d v1.0.0
git push origin --delete v1.0.0

Troubleshooting

# Fix "detached HEAD"
git checkout main

# Recover deleted branch
git reflog
git checkout -b recovered-branch abc1234

# Find lost commits
git fsck --lost-found

# Reset to remote state
git fetch origin
git reset --hard origin/main

Git Aliases

Add to ~/.gitconfig:

[alias]
  co = checkout
  br = branch
  ci = commit
  st = status
  lg = log --oneline --graph --decorate -20
  unstage = reset HEAD --
  last = log -1 HEAD
  amend = commit --amend --no-edit

Tips

  • Always pull before starting new work
  • Commit early and often
  • Write meaningful commit messages
  • Use branches for features/fixes
  • Never force push to shared branches
  • Review changes before committing with git diff

Resources

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.