Cheatsheets

Git Cheat Sheet

Updated July 28, 2026 · Written by PWNMI — see About.

Git tracks a project's full history as a series of commits, synced between a local copy and one or more remotes. On this site it's the standard way to pull down a lab environment or a public PoC — but it's also the tool worth knowing for your own engagement notes, custom scripts, and — a genuinely offensive use case — reconstructing an application's source from a .git directory someone left publicly exposed.

Red Team / Offensive Use

Most of git's role in engagement work is infrastructure, the same as Docker: cloning lab environments and public PoCs, and versioning your own recon notes and tooling so nothing gets lost between sessions. But git itself is occasionally the finding: a .git folder accidentally left accessible on a live web server exposes the application's entire commit history over plain HTTP, even if the current live version has since had secrets removed — git history doesn't forget, and a credential committed once and later deleted is still sitting in an earlier commit, retrievable by anyone who can reach .git/.

Established Cheatsheet

git-scm.com Reference — the official documentation for every command and flag.

PWNMI's Top 7 Use Cases

  • git clone <url> — clone a repo, full history included; the standard first step for pulling down a lab environment or PoC
  • git clone --depth 1 <url> — shallow clone, latest snapshot only, no history — faster when you just need the current code from a large repo
  • git log --oneline --graph --all — a compact visual history across every branch, the fastest way to orient yourself in an unfamiliar repo
  • git log -p -- <path> — full diff history for one specific file, useful for seeing exactly how a piece of code — or a credential — changed over time
  • git diff <ref1> <ref2> — compare two commits, branches, or tags directly
  • git-dumper http://target/.git/ ./dumped-repo — reconstruct a full repo, including history, from a .git directory mistakenly left web-accessible; a real, common finding worth checking for on any target (git-dumper automates the walk of .git/index and .git/objects/)
  • git stash — shelve uncommitted local changes without a full commit, useful for quickly switching context and coming back later

Next step

New to git entirely? Start with Git for Security Work for the underlying workflow — staging, commits, branches — behind every command here. To see git clone used as step one of an actual lab, see CVE-2026-62183 (Apache Syncope).