| name | git-essentials |
| description | Essential Git commands and workflows for version control, branching, and collaboration. |
| layer | base |
| skill_type | tool |
| dependencies | [] |
Git Essentials
Overview
git-essentials is the NeuroClaw base skill for all version control operations. It provides the essential Git commands for initializing repositories, staging, committing, branching, merging, working with remotes, viewing history, undoing changes, stashing, rebasing, tagging, and common daily workflows.
This skill serves as the foundation for any project that requires reproducible code management, experiment tracking, or collaboration inside NeuroClaw.
Research use only — always combine with git-workflows for advanced operations.
Initial Setup
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
git init
git clone https://github.com/user/repo.git
git clone https://github.com/user/repo.git custom-name
Basic Workflow
Staging and committing
git status
git add file.txt
git add .
git add -A
git commit -m "Commit message"
git commit -am "Message"
git commit --amend -m "New message"
git commit --amend --no-edit
Viewing changes
git diff
git diff --staged
git diff file.txt
git diff commit1 commit2
Branching & Merging
Branch management
git branch
git branch -a
git branch feature-name
git checkout feature-name
git switch feature-name
git checkout -b feature-name
git switch -c feature-name
git branch -d branch-name
git branch -D branch-name
git branch -m old-name new-name
Merging
git merge feature-name
git merge --no-ff feature-name
git merge --abort
git diff --name-only --diff-filter=U
Remote Operations
Managing remotes
git remote -v
git remote add origin https://github.com/user/repo.git
git remote set-url origin https://github.com/user/new-repo.git
git remote remove origin
Syncing with remote
git fetch origin
git pull
git pull --rebase
git push
git push -u origin branch-name
git push --force-with-lease
History & Logs
Viewing history
git log
git log --oneline
git log --graph --oneline --all
git log -5
git log --author="Name"
git log --since="2 weeks ago"
git log --until="2024-01-01"
git log -- file.txt
Searching history
git log --grep="bug fix"
git log -S "function_name"
git blame file.txt
git bisect start
git bisect bad
git bisect good commit-hash
Undoing Changes
Working directory
git restore file.txt
git checkout -- file.txt
git restore .
Staging area
git restore --staged file.txt
git reset HEAD file.txt
git reset
Commits
git reset --soft HEAD~1
git reset --hard HEAD~1
git revert commit-hash
git reset --hard commit-hash
Stashing
git stash
git stash save "Work in progress"
git stash list
git stash apply
git stash pop
git stash apply stash@{2}
git stash drop stash@{0}
git stash clear
Rebasing
git rebase main
git rebase -i HEAD~3
git rebase --continue
git rebase --skip
git rebase --abort
Tags
git tag
git tag v1.0.0
git tag -a v1.0.0 -m "Version 1.0.0"
git tag v1.0.0 commit-hash
git push origin v1.0.0
git push --tags
git tag -d v1.0.0
git push origin --delete v1.0.0
Advanced Operations
Cherry-pick
git cherry-pick commit-hash
git cherry-pick -n commit-hash
Submodules
git submodule add https://github.com/user/repo.git path/
git submodule init
git submodule update
git clone --recursive https://github.com/user/repo.git
Clean
git clean -n
git clean -f
git clean -fd
git clean -fdx
Common Workflows
Feature branch workflow:
git checkout -b feature/new-feature
git add .
git commit -m "Add new feature"
git push -u origin feature/new-feature
git checkout main
git pull
git branch -d feature/new-feature
Hotfix workflow:
git checkout main
git pull
git checkout -b hotfix/critical-bug
git commit -am "Fix critical bug"
git push -u origin hotfix/critical-bug
git checkout main && git pull
Syncing fork:
git remote add upstream https://github.com/original/repo.git
git fetch upstream
git checkout main
git merge upstream/main
git push origin main
Useful Aliases
Add to ~/.gitconfig:
[alias]
st = status
co = checkout
br = branch
ci = commit
unstage = reset HEAD --
last = log -1 HEAD
visual = log --graph --oneline --all
amend = commit --amend --no-edit
Tips
- Commit often, perfect later (interactive rebase)
- Write meaningful commit messages
- Use
.gitignore for files to exclude
- Never force push to shared branches
- Pull before starting work
- Use feature branches, not main
- Rebase feature branches before merging
- Use
--force-with-lease instead of --force
Common Issues
Undo accidental commit:
git reset --soft HEAD~1
Recover deleted branch:
git reflog
git checkout -b branch-name <commit-hash>
Fix wrong commit message:
git commit --amend -m "Correct message"
Resolve merge conflicts:
git add resolved-files
git commit
When to Call This Skill
- Any time you need basic version control inside NeuroClaw
- Before running
git-workflows for advanced operations
- When managing experiment code, paper drafts, or data processing scripts
- After
dependency-planner installs new tools that require Git
Complementary / Related Skills
git-workflows → advanced operations (rebase, bisect, worktree, sparse checkout, etc.)
claw-shell → all Git commands are safely executed through claw-shell
Reference
Official docs: https://git-scm.com/doc
Pro Git book: https://git-scm.com/book
Visual Git guide: https://marklodato.github.io/visual-git-guide/
Created At: 2026-03-19 00:00 HKT
Last Updated At: 2026-03-25 23:57 HKT
Author: chengwang96