Git Github Workflow
ASecurityExpert Git and GitHub practice — repository setup, .gitignore and line endings, branching, commit and pull-request quality, merge strategy, rulesets and branch protection, CODEOWNERS, GitHub Actions security (least-privilege permissions, SHA-pinned actions), Dependabot, secret scanning, releases with SemVer and changelogs, recovering from mistakes (reflog, revert, bisect), safe history rewriting and repo hygiene for solo developers and teams. Use when the user says "git", "GitHub", "commit", ...
- 3 stars
- 0 votes
- 0 copies
- 3 views
- Added December 1, 2026
Works with
Security analysis
100/100Pro scans all 10 files and shows the line behind each finding
npx -y skills add Kin9Zeus/senior-engineer-skills --skill git-github-workflow --agent claude-codeAre you the author of Git Github Workflow?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/kin9zeus-git-github-workflow)---
name: git-github-workflow
description: Expert Git and GitHub practice — repository setup, .gitignore and line endings, branching, commit and pull-request quality, merge strategy, rulesets and branch protection, CODEOWNERS, GitHub Actions security (least-privilege permissions, SHA-pinned actions), Dependabot, secret scanning, releases with SemVer and changelogs, recovering from mistakes (reflog, revert, bisect), safe history rewriting and repo hygiene for solo developers and teams. Use when the user says "git", "GitHub", "commit", "branch", "pull request", "merge conflict", "rebase", "undo a commit", "I pushed a secret", "set up a repo", "branch protection", "CI on GitHub", "GitHub Actions", "Dependabot", "release", "tag", "versioning", "changelog", "monorepo", "gitignore", "make my repo professional", "subir a GitHub", "ramas" or "control de versiones"; when creating or publishing a repository; and in phase 4 of any new project. By Devleck.
license: MIT
---
# Git and GitHub Workflow
Version control is the project's memory and its safety net. Done well it makes every
change reviewable, reversible and attributable. Done badly it leaks secrets, loses work
and makes releases a gamble.
**Scope:** the user's own repositories. **Outward-facing or irreversible actions need
the user's explicit confirmation each time:** making a repository public, pushing to a
branch that deploys automatically, force-pushing, publishing a release, deleting branches
or tags, changing repository or organisation settings. State what will happen, then wait
for a clear yes.
> GitHub's features and defaults change. Where this skill names a setting, **confirm in
> the current GitHub Docs** before telling someone to rely on it.
---
## The order of work for a new repository
```
1 CREATE private first; default branch main; no secrets yet
2 BASELINE .gitignore · .gitattributes · LICENSE · README skeleton · SECURITY.md
3 FIRST COMMIT on main, then everything through branches and pull requests
4 PROTECT ruleset on main · status checks · no force-push or deletion
5 AUTOMATE CI (tests, lint, build) · Dependabot · secret scanning + push protection
6 TEMPLATE PR template · issue forms · CODEOWNERS for sensitive paths
7 VERIFY run git-hygiene · clone fresh and run the README steps
8 PUBLISH (only with a yes) run the public gate below · description, topics, release
```
```bash
bash skills/git-github-workflow/scripts/git-hygiene.sh . # read-only; leads, not findings
```
---
## 1. Before anything is public — the gate
Making a repository public is **near-irreversible**: forks, clones and scrapers keep
copies. All of these must pass, and the owner must say yes in the conversation:
| Check | How |
|---|---|
| **No secrets in the whole history** | Scan history, not just the tree — a dedicated scanner (e.g. gitleaks and trufflehog; they catch different things) plus `security-hardening/scripts/secret-scan.sh`. Also search history for `.env`, key files, connection strings, dumps |
| A found secret is **never fixed by deleting the file** | It stays in history. **Rotate it first** (`security-incident-response`), then clean history or publish a fresh repo. Purging without rotating leaves the key live |
| **No personal or client data** | Emails, phone numbers, ids, internal URLs, customer names, staging identifiers. Use a role address, not a personal one |
| **Right to publish** | Client code needs the client's/employer's permission; brand assets stay theirs; check contracts on who owns the code |
| **Licence decided** | Open source (MIT/Apache-2.0/GPL…) only if you want reuse; otherwise state "all rights reserved" explicitly. No licence ≠ open |
| **No large binaries** | Videos, datasets, raw design files bloat clones; use Git LFS or external storage |
| **README, SECURITY.md, honest badges** | Numbers verified against the code, not remembered |
## 2. Commits
```
<type>(<scope>): <subject in the imperative, ≤ 72 chars>
<body: WHY this change, what was verified, what was deliberately not changed>
<footer: Closes #123 · BREAKING CHANGE: … · Co-authored-by: …>
```
- **One logical change per commit.** Do not mix a refactor with a feature, or a dependency
bump with copy edits. Reviewers (and `git bisect`) depend on it.
- **Conventional Commits** types (`feat`, `fix`, `docs`, `refactor`, `test`, `perf`,
`build`, `ci`, `chore`, `revert`) make changelogs and version bumps mechanical — adopt
them if the team wants automation; consistency matters more than the exact style.
- **Match the repository's existing style and language.**
- **Never commit:** secrets, `.env`, build output, dependencies, editor/OS junk, large
binaries, generated files that can be rebuilt.
- **After every commit** run `git show --stat HEAD` and confirm everything intended is
in it (a forgotten `git add` is the classic mistake) and nothing else is.
- Attribution: add `Co-authored-by:` trailers only with the co-author's permission and
correct address.
## 3. Branching and pull requests
- **Trunk-based with short-lived branches** (`feat/…`, `fix/…`, `docs/…`, 1–3 days) for
anything continuously deployed; Git Flow only for versioned products customers upgrade
at their own pace. Feature flags decouple deploy from release.
- **Pull requests for real changes**, even solo: they give CI a gate, a record, and a
moment to re-read your own diff. Keep them **small** (a reviewer can understand them in
ten minutes); split by concern.
- **PR description:** what and why, how it was verified (commands/screenshots), risk and
rollback, linked issue (`Closes #N`).
- **Review:** correctness, security (authorisation, input, secrets), tests, readability;
comments say *why*; authors respond to every comment; approve only what you understand.
- **Merge strategy — decide once and write it down:**
| Strategy | History | Use when |
|---|---|---|
| **Squash** | One commit per PR | Messy branch history; linear main |
| **Rebase** | Linear, keeps commits | Clean, well-structured commits |
| **Merge commit** | Preserves branch and attribution | You want each PR visible and co-author trailers intact |
- **Delete the branch after merge.** Delete only fully-merged branches; record the SHA
first so it can be restored.
- Do not push straight to a branch that auto-deploys unless the change was verified.
Details, conflict resolution and recovery: `references/git-mastery.md`.
## 4. Protecting `main` — rulesets
Use **rulesets** (the current mechanism; they can coexist with classic branch protection,
and the most restrictive rule applies — check current docs for availability on your plan):
- Block **force-push and deletion** of `main`
- Require **status checks** (CI) to pass, and branches up to date where sensible
- Require **pull requests**; require approvals **only if there is a second person who can
approve** — a solo maintainer who requires approvals locks themselves out (allow a
bypass for the maintainer or leave approvals off)
- Optionally: signed commits, linear history, merge queue, CODEOWNERS review for sensitive
paths (auth, payments, migrations, CI config, infrastructure)
- Restrict tag creation/deletion for release tags
## 5. GitHub Actions — secure by default
```yaml
permissions: # at top level: least privilege
contents: read
concurrency: { group: ci-${{ github.ref }}, cancel-in-progress: true }
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@<full-commit-sha> # pin to a SHA; Dependabot keeps it current
```
- **Declare `permissions:` explicitly**, minimal; widen per job only when needed.
- **Pin third-party actions to a full commit SHA** (a tag can be moved); let
Dependabot's `github-actions` ecosystem update the pins. Pinning does not protect nested
actions — prefer few, well-known actions.
- **Never run untrusted code with secrets:** avoid `pull_request_target`/`workflow_run`
that check out and execute fork code; treat PR titles, branch names and issue bodies as
untrusted input (script injection through `${{ }}` in `run:`); pass them via environment
variables.
- Secrets only to the jobs that need them; **prefer OIDC** short-lived cloud credentials
to stored keys (`cloud-security`); use **environments** with required reviewers for
production deploys.
- `timeout-minutes` on every job; cache dependencies keyed by the lockfile.
- Run the same checks locally before pushing; **the badge goes in the README only after CI
is green on `main`.**
- Re-check current GitHub guidance — new controls (workflow lockfiles, policy settings)
appear regularly.
## 6. Dependencies and security features
- **Dependabot:** version updates on a schedule, minor/patch **grouped**, majors reviewed by
hand, a limit on open PRs, `github-actions` ecosystem included. Un-tuned Dependabot buries
a repo in PRs — tune it.
- **Dependabot alerts**, **secret scanning with push protection**, **private vulnerability
reporting** enabled (availability depends on repo visibility/plan — check); **code
scanning (CodeQL)** for application code.
- **Lockfile committed**; CI installs from it with the frozen flag; audit in CI
(`security-hardening/references/supply-chain.md`).
- `SECURITY.md` says how to report privately, what is in scope, and how fast you respond.
## 7. Releases and versioning
- **SemVer** (`MAJOR.MINOR.PATCH`): breaking → major; compatible feature → minor; fix →
patch. Pre-1.0: be explicit about stability.
- Keep a **CHANGELOG** (Keep a Changelog style) written for humans; release notes say what
changed, why it matters, upgrade steps, known issues — with **verified** facts.
- Tag annotated: `git tag -a v1.2.0 -m "…"` on a commit whose CI is green; create the GitHub
release from the tag (`gh release create`); attach artefacts; consider immutable
releases and artifact attestations for shipped binaries (check current docs).
- **Hotfix flow:** branch from the release tag, fix, test, tag a patch, merge back.
- Never move or delete a published tag; publish a new version instead.
`references/workflows-and-releases.md` — branching models, monorepos, release automation.
## 8. Repo hygiene
Root stays short and meaningful (guides in `docs/`); `.gitignore` covers env files, build
output, dependencies, editor and OS files; `.gitattributes` fixes line endings and marks
generated/vendored files; shell scripts tracked **executable** (`git update-index
--chmod=+x`; Git on Windows does not set it); description, topics and homepage set; empty
Wiki/Projects tabs disabled; stale branches pruned; issue and PR templates only if people
will use them; LICENSE, README, SECURITY, CODE_OF_CONDUCT/CONTRIBUTING when others
contribute. Never rewrite published history for cosmetics.
## 9. When something goes wrong
| Situation | First move |
|---|---|
| Committed a secret | **Rotate it now**, then remove from history (`filter-repo`/BFG), force-push with coordination, everyone re-clones. See `security-incident-response` |
| Committed to the wrong branch | `git switch -c correct-branch` then reset the wrong one (only if not pushed) |
| Need to undo a pushed commit | `git revert <sha>` (safe, adds a commit); do not rewrite shared history |
| "I lost my work" | `git reflog` — commits survive for weeks; `git switch -c rescue <sha>` |
| Merge conflict | Understand both sides, resolve, run tests, `git merge --continue`; use `git rerere` for repeats |
| Bug appeared sometime | `git bisect` with a failing test |
| Wrong files in the last commit | `git commit --amend` (not pushed) or a follow-up commit |
| Pushed a large file | Remove with history rewrite *and* check LFS; coordinate |
---
## What people get wrong
- **Fixing a leaked key by deleting the file** and never rotating it.
- **Mega-commits** ("update") that mix five changes and can't be reverted cleanly.
- **Long-lived branches** that become merge projects.
- **Force-pushing shared branches**, or rewriting history that others have pulled.
- **No `.gitignore` until `node_modules` is committed.**
- **Requiring approvals as a solo maintainer** and locking yourself out.
- **Unpinned third-party Actions** and `pull_request_target` with fork code checkout.
- **A green badge on a red build.**
- **Un-tuned Dependabot** noise that trains everyone to ignore security PRs.
- **Shell scripts committed non-executable** (fails on Linux CI after working on Windows).
- **Publishing a repo "to look professional"** before scanning history.
## Report format
Findings: **where → what is wrong → consequence → fix (exact command/setting) → how to
verify**. End with **What I could not verify** (e.g. server-side settings the CLI could
not read).
---
## References, templates and scripts
- `references/git-mastery.md` — mental model, daily commands, rebase vs merge, recovery, bisect, stash, worktrees, history surgery, hooks, line endings, LFS, submodules
- `references/github-setup.md` — repo creation, rulesets, security features, Actions hardening, environments, community files, Pages, profile README
- `references/workflows-and-releases.md` — branching models, PR size and review, monorepos, SemVer, changelog, release automation, hotfixes
- `templates/pull-request-template.md` · `templates/github-repo-files.md` (CODEOWNERS, Dependabot, CI, issue forms) · `templates/security-policy.md` · `templates/release-notes.md`
- `scripts/git-hygiene.sh` / `scripts/git-hygiene.ps1` — read-only repo health check
- Related: `engineering-standards`, `devops-platform`, `security-hardening`, `cloud-security`, `release-readiness`
Files in this skill
- SKILL.md
- references/git-mastery.md
- references/github-setup.md
- references/workflows-and-releases.md
- scripts/git-hygiene.ps1
- scripts/git-hygiene.sh
- templates/github-repo-files.md
- templates/pull-request-template.md
- templates/release-notes.md
- templates/security-policy.md
Attribution
Related skills
View all in security →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.