git-workflow
/git-workflow
Keep a Git history that is easy to review, bisect, release and recover: short-lived branches off trunk, small atomic commits with clear messages, rebase for local work and never for shared history, safe force pushes, recovery with reflog and revert, and history rewrites with git-filter-repo when a secret or huge file got in. Use when the user asks about a branching strategy, rebase or merge, squash, merge conflicts, undoing a commit, lost work, a detached HEAD, force pushing, removing a secret or large file from history, .gitignore, .gitattributes, line endings, Git LFS, submodules or signed c
- Author
- devpilotX ↗
- Repository
- ai-skill-ai ↗
- Licence
- MIT
- Last repository change
- 31.10.2026
Assessment and security
- Files in this package
- 5
- Scripts
- 1
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 31.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
- 1 scripts in this package. Review them before installing, as Claude may execute them.
Scripts: scripts/repo_audit.py
What it does and when to use it
Keep a Git history that is easy to review, bisect, release and recover: short-lived branches off trunk, small atomic commits with clear messages, rebase for local work and never for shared history, safe force pushes, recovery with reflog and revert, and history rewrites with git-filter-repo when a secret or huge file got in. Use when the user asks about a branching strategy, rebase or merge, squash, merge conflicts, undoing a commit, lost work, a detached HEAD, force pushing, removing a secret or large file from history, .gitignore, .gitattributes, line endings, Git LFS, submodules or signed c
Original author description
Keep a Git history that is easy to review, bisect, release and recover: short-lived branches off trunk, small atomic commits with clear messages, rebase for local work and never for shared history, safe force pushes, recovery with reflog and revert, and history rewrites with git-filter-repo when a secret or huge file got in. Use when the user asks about a branching strategy, rebase or merge, squash, merge conflicts, undoing a commit, lost work, a detached HEAD, force pushing, removing a secret or large file from history, .gitignore, .gitattributes, line endings, Git LFS, submodules or signed c
How it works
- When to use and when to stay off
- Non-negotiables
- Procedure
- Self-audit
- What this cannot do
SKILL.md preview
--- name: git-workflow description: "Keep a Git history that is easy to review, bisect, release and recover: short-lived branches off trunk, small atomic commits with clear messages, rebase for local work and never for shared history, safe force pushes, recovery with reflog and revert, and history rewrites with git-filter-repo when a secret or huge file got in. Use when the user asks about a branching strategy, rebase or merge, squash, merge conflicts, undoing a commit, lost work, a detached HEAD, force pushing, removing a secret or large file from history, .gitignore, .gitattributes, line endings, Git LFS, submodules or signed commits. Audits a repository with scripts/repo_audit.py for oversized blobs, credential files, tracked junk, case collisions, paths Windows cannot create, mixed line endings and commit message drift. Triggers on git rebase, merge conflict, undo commit, git reflog, force push, git-filter-repo, gitignore, line endings, git lfs, trunk-based. For CI checks use quality-gates. For releases use release-manage." license: MIT metadata: version: 1.0.1 suite: ai-skill --- # Git workflow Most Git trouble is self-inflicted and expensive to undo once others have cloned: a force push that erased a colleague's commits, a `.env` file pushed to a public repository, a 300 MB video in history that every clone downloads forever, a week-long branch with a conflict in every file, a merge called "fix stuff" that nobody can bisect through. This skill keeps changes small and moving, makes every destructive command reversible before it runs, and treats rewriting shared history as a planned operation with a backup and a reason. ## When to use and when to stay off Run when the work is how changes move through Git: choosing a branch model and merge method, writing commits and messages, rebasing and resolving conflicts, pushing safely, undoing and recovering, setting up `.gitignore`, `.gitattributes` and LFS, auditing a repository before it is pushed or made public, or removing a secret or a large file from history. Stay off, and route instead, when: - The work is the CI checks a pull request must pass or the branch protection rules that require them. `quality-gates` owns those. - The work is version numbers, tags, changelogs or release branches as a release process. `release-manage` owns releases. - The work is judging the content of a diff. `code-review` owns review. - The work is pre-commit hooks, lockfiles or the developer setup. `devex-tooling` owns local tooling. - The question is which commit introduced a bug. `debug-method` owns bisection strategy; this skill covers the Git commands. - A secret has leaked and access must be cut. `security-hardening` owns rotation and the wider response; step 7 here cleans the history afterwards. The user says "stop", "I've decided", or "just execute": comply at once and stay off for the rest of the session unless asked again. ## Non-negotiables These override everything else in this file. 1. Published history is not rewritten without the agreement of everyone who has it, a mirror backup, and a written reason. Shared branches move forward by revert, not by reset. 2. Force pushes use `--force-with-lease --force-if-includes`, go only to branches you own, and never to the default branch, which is protected. 3. A leaked secret is rotated first. Rewriting history comes after, if at all, and follows the procedure in `references/history-rewrite.md`. 4. Each commit is one logical change that builds and passes tests, with a subject under 72 characters in the imperative and a body that says why. No WIP or fixup commits reach the default branch, and a repository that uses Conventional Commits keeps using them. 5. Branches live a day or two and merge into trunk. Work that takes longer ships behind a flag rather than on a long branch; DORA's research links three or fewer active branches and daily merges with better delivery. 6. Before any destructive command (`reset --hard`, `clean -fd`, `restore` on unstaged work, `filter-repo`), stash or commit first and note where `HEAD` was. Run `scripts/repo_audit.py` before the first push of a repository, before making one public, and before any rewrite. ## Procedure Branch models, merge methods, commit and message rules, integration and conflicts are in `references/branching-and-commits.md`. The undo and recovery table is in `references/recovery.md`. The rewrite procedures for secrets, large files and identities, with their sources, are in `references/history-rewrite.md`. ### Step 1, audit the repository ``` python3 scripts/repo_audit.py . --strict ``` It reads the repository without changing it and reports blobs anywhere in history over GitHub's 50 MiB warning and 100 MiB block, tracked files over 5 MiB, credential files tracked now or in the past (`.env`, private keys, keystores, Terraform state, kubeconfig), tracked dependency folders, caches and OS files, paths that differ only by case or that Windows cannot create, CRLF files beside LF ones with no `.gitattributes`, WIP and one-word commits, branches already merged, a stale `origin/HEAD`, and submodules fetched over plain HTTP. Content scanning for secrets stays with gitleaks. ### Step 2, set the branch model and merge method Trunk-based by default: protected default branch, short-lived branches named by type and topic, one merge method for the whole repository. Write the choice in the contributing guide so pull requests arrive the same way. ### Step 3, set up the repository files A `.gitignore` built from the stack's standard template plus the project's build output and local environment files, committed before the first real commit. A `.gitattributes` with `* text=auto`, `eol` rules for scripts that must keep their line endings, and `binary` or LFS rules for large binary types. Fix existing line endings once with `git add --renormalize .` in its own commit. ### Step 4, commit so the history reviews and bisects well Stage with `git add -p`, check with `git diff --cached`, and write the message from the template in the reference. Separate refactors from behaviour changes. During review, add `--fixup` commits and fold them in with `git rebase -i --autosquash` before merging. ### Step 5, integrate and push safely Fetch, rebase local work onto the latest trunk, resolve conflicts with `zdiff3` and `rerere` on, run the tests, then push with `--force-with-lease --force-if-includes`. Once a branch is shared, merge trunk into it instead of rebasing, or agree the rebase with the people using it. ### Step 6, undo and recover Find the situation in `references/recovery.md` and run the matching command. Read `git status` and `git reflog` before acting, branch from any commit you are about to lose, and prefer `git revert` on anything already pushed. ### Step 7, rewrite history only when it pays For a secret: rotate, then follow the GitHub procedure with git-filter-repo 2.47 or later and `--sensitive-data-removal`, count the affected pull requests before pushing, push with `--mirror`, ask GitHub Support to purge cached views and pull request references, and have every collaborator re-clone. For large files, move them to LFS with `git lfs migrate import` or remove them. Re-run the audit afterwards; it should no longer list them. ### Step 8, keep the repository tidy Delete merged branches locally with `git branch -d` and on the remote after merge, prune stale remote-tracking refs with `git fetch --prune`, fix a stale `origin/HEAD` with `git remote set-head origin --auto`, and let `git maintenance start` keep large repositories fast. ## Self-audit - `repo_audit.py --strict` reports no high or medium findings, or each one is explained in writing. - The default branch is protected, and the merge method and branch naming are written down. - `.gitignore` and `.gitattributes` exist, and no credential file or dependency folder is tracked. - No WIP or fixup commit reached the default branch, and recent subjects stay under 72 characters. - Every force push in the session used `--force-with-lease --force-if-includes` on a branch the user owns. - Any rewrite had a mirror backup, a rotated secret, a count of affected pull requests, and a message to collaborators. ## What this cannot do It cannot take back a secret that was public. Rewriting history hides it from new clones, but every existing clone, fork, cache and scraper keeps it, which is why rotation comes first. It cannot see other people's clones or forks, so it cannot confirm a cleanup is complete everywhere. It cannot change hosting settings such as branch protection, merge methods or push protection without the access to do so; it writes the exact settings to apply. It does not decide who may have used a leaked credential. Ask the security lead: "This credential was in our repository from this time to this time, publicly visible from this time. Has it been rotated everywhere it is used, and do the provider's access logs show any use from unknown addresses in that window?"
Files in this package (5)
- SKILL.md 9 KB
- references/branching-and-commits.md 5 KB
- references/history-rewrite.md 4 KB
- references/recovery.md 3 KB
- scripts/repo_audit.py 28 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · devpilotX/ai-skill-ai | 100 | MIT |
| event4u-app/agent-config | 100 | MIT |
| lee-w/maigo | 100 | MIT |
| hakula139/plugins | 100 | MIT |
| ericrisco/rsc-harness | 100 | MIT |
| Sanit-mann/The-Insectoids | 100 | MIT |
| eliyce/paqad-ai | 100 | MIT |
| langfuse/langfuse | 100 | MIT |
| Muvon/octomind-tap | 100 | Apache-2.0 |
Database snapshot: 13.11.2026 · package version 497da916b967 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 90rs-git
Use for any version-control work from design to production release — branching, commits, messages, reviews/merge requests, tags, changelogs, hotfixes, history surgery, repository hygiene — on any Git host (GitHub, GitLab, Bitbucket, Gitea, Azure DevOps, Gerrit, plain SSH, or no… - 100git
Everyday Git workflows and recovery: status/diff/log, branching, committing, merging vs rebasing, undoing mistakes, resolving conflicts, and inspecting history. Use when users ask how to do something in Git, are stuck (detached HEAD, merge conflict, accidental commit), or want… - 100git
Full git workflow for developers: status, staging, commits, branches, push/pull, merge/rebase, conflict resolution, stash, history (log/blame/bisect), remotes, tags, worktrees, cherry-pick, and recovery with reflog. The everyday operations live in the git tool; this skill covers… - 100git-master
MUST USE for ANY git operations: atomic commits, rebase/squash/fixup, and history search (blame, bisect, log -S, reflog). Load it before running git yourself, or pass load_skills=['git-master'] to the task that commits. Triggers: 'commit', 'rebase', 'squash', 'who wrote', 'when… - 100github-master
Expert Git & GitHub: workflows, history recovery, pull requests, branch protection, and Actions CI/CD. Trigger keywords: git, GitHub, merge conflict, rebase, cherry-pick, reflog, bisect, force push, pull request, branch protection, GitHub Actions, CI/CD, release, conventional… - 100conflict-resolution
Use this skill when the user says 'merge conflict', 'rebase conflict', 'resolve conflicts', 'conflict markers', 'ours vs theirs', 'git rerere', 'abort rebase', 'lost commits', 'git reflog', 'undo a merge', 'revert a merge', 'detached HEAD', 'recover deleted branch', 'git…