{"canonical_url":"https://engineer.company/glossary/git/","content_markdown":"# Git\n\n## What it is\n\nGit is a distributed version control system: a program that records the state of\na set of files as a chain of snapshots, so that any earlier state can be looked\nat, compared with the present or brought back. The project writes the name as\nGit and the command as `git`; both mean the same tool.\n\nEach snapshot is a commit. A commit stores what every tracked file looked like\nat that moment, who made the change and when, a message saying why, and a\npointer to the commit or commits that came before it. Git stores a file it has\nalready seen only once: when a file is unchanged between two commits, the new\nsnapshot points at the copy already on disk instead of writing it again, so a\nlong history costs far less space than a full copy per commit would.\n\nEverything inside is named by its content. Before git stores a file, a directory\nlisting or a commit, it computes a checksum over the bytes, in the classic\nformat a SHA-1 hash written as 40 hexadecimal characters, and that checksum\nbecomes the object's name. Change a single byte and the name changes with it,\nalong with the name of every commit built on top. That is how git notices\ncorruption, and it is why a commit identifier still points at exactly the same\ncode years later.\n\nDistributed means every copy is complete. Cloning a repository brings down the\nentire history, not just the latest files, so reading the log, comparing two\nversions or making a commit all happen on the local disk with no server\ninvolved. Sharing work is a separate, deliberate step: you push your commits to\nanother copy, or fetch commits from one and merge them. Any copy can act as the\nserver; in most teams one agreed copy, often on a hosted service, plays that\npart by convention rather than by design.\n\nA day's work moves through three places. The working tree holds the files you\nedit. The staging area, also called the index, holds what the next commit will\ncontain, which lets you commit part of your changes and keep the rest for later.\nThe git directory, `.git` at the top of the project, holds the object database\nand every reference. A branch is nothing more than a movable name pointing at\none commit, which is why creating one is instant.\n\nGit was written in 2005 by Linus Torvalds and the Linux kernel community, after\nthe free-of-charge status of BitKeeper, the proprietary tool they had been\nusing, was revoked. The goals they set were speed, a simple design, strong\nsupport for thousands of parallel branches, full distribution, and the capacity\nto handle a project the size of the kernel.\n\n## Why it matters\n\nVersion control answers the questions that arrive as soon as more than one\nperson, or one person over more than a week, touches the same files: what\nchanged, when, by whom and why. Kept by hand, the answers live in memory, in\nfile names like `final-v3` and in email threads. With git they live beside the\ncode, attached to each change, where anyone can search them.\n\nThe distributed design changes how a team works day to day. Every clone holds\nthe whole history, so nobody waits on a central server to read the log or to\ncommit, and a server outage leaves everyone able to keep working. Branches are\ncheap, so every feature, fix or experiment can get one, be reviewed on its own\nand be merged when it is ready, while the main line stays fit to ship.\n\nThe same design makes git conservative with data. Nearly every operation only\nadds to the object database, so committed work is hard to lose: a branch deleted\nby mistake, a rebase that went sideways or a reset to the wrong commit can\nusually be undone. The safety net is the reflog, a local record of where each\nbranch pointed and when, kept by default for 90 days for commits that are still\nreachable and 30 days for those that are not.\n\nGit is also the common ground under most of the other tools in a delivery chain.\nForges, review tools, build systems, deploy scripts and static site generators\nall read from it, which turns the history into a source of facts well beyond the\ncode: the day a page last changed, the commit a release was built from, the\nchange a bug arrived with.\n\n## What it looks like in practice\n\nThis company's own code shows three sides of that.\n\nThe source used to live on a third-party hosting service. It now sits on\n[a git server the company runs on its own hardware](/portfolio/your-code-on-your-own-hardware/):\na single binary supervised by the operating system, picked for being SSH-first\nwith no administrative web interface. Clones and pushes travel over SSH to port\n23231, which listens on loopback alone, so a remote outside the host reaches it\nthrough a jump host; anonymous and keyless sessions are both refused, and every\ndeclared repository is marked private. The page is plain about the price:\nrunning your own forge means owning authentication, access control, storage and\nbackups as well.\n\nFull copies of history on several machines are easy to mistake for a backup. The company's\n[backup and restore-test implementation](/portfolio/backups-that-have-actually-been-restored/)\nwas designed to extend recovery beyond a provider snapshot. Its restic scripts and systemd\nunits support a database dump where configured, encrypted deduplicated snapshots to storage\nat another provider over SFTP, retention pruning and integrity checks. A separate monthly\nworkflow restores a known file to a scratch location and compares its bytes. That test must\nactually run before it proves a recovery position: the implementation record dated\n2026-10-27 says the timers were disabled without a configured repository and records no\ncompleted live restore. No number of clones on laptops supplies that missing evidence.\n\nThe history also feeds the site itself. [The site's credits page](/credits/)\nrecords that the [W3C Feed Validator](https://validator.w3.org/feed/) warns that\nmost entries in the feeds share a modification date, and that the warning is\ncorrect: the dates come from git history, and most of those pages really were\nwritten in a handful of commits. The site would rather show the warning than\nmake a date up. The history says what happened, including that much of it\nhappened at once.\n\nOne command reads such a fact back. This prints the short identifier, the commit\ndate in ISO 8601 form and the subject of the last commit that touched one file:\n\n```sh\ngit log -1 --format='%h %cI %s' -- README.md\n```\n\n## Where it goes wrong\n\n- **A secret committed once stays in history.** Deleting the file in the next\n  commit removes it from the latest snapshot and leaves it in the one before,\n  which every clone already carries. Treat the credential as exposed and rotate\n  it; rewriting history afterwards narrows the spread, but copies made in\n  between keep the old commits.\n- **A force push replaces someone else's work.** `git push --force` switches off\n  the check that the remote branch is an ancestor of what you push, so commits a\n  colleague pushed in the meantime drop off the branch. `--force-with-lease`\n  updates the remote only while it still points where you last saw it.\n- **Clones get treated as the backup.** A laptop copy lags behind, holds only\n  the branches its owner happened to fetch, and has never been restored from on\n  purpose. Issues, access rules and the rest of a forge's own data sit outside\n  the repository altogether.\n- **A large binary file bloats every clone for good.** Git keeps each version of\n  each file and every clone downloads all of them, so a video committed by\n  accident and deleted the next day still travels to every machine that clones\n  the project afterwards.\n- **Work kept in one place disappears with that place.** The reflog that rescues\n  a bad reset lives on one machine and expires. Commits that were never pushed\n  exist nowhere else, and a branch left alone for months drifts so far that\n  merging it back becomes a project of its own.\n\n## Further reading\n\n- [Git documentation](https://git-scm.com/doc) — the reference manual, the book\n  and the videos, from the project itself.\n- [Pro Git](https://git-scm.com/book/en/v2) — the whole book online, from a\n  first commit to the object database underneath.\n- [What is Git?](https://git-scm.com/book/en/v2/Getting-Started-What-is-Git%3F)\n  — snapshots, local operations, checksums and the three states in one chapter.\n- [A Short History of Git](https://git-scm.com/book/en/v2/Getting-Started-A-Short-History-of-Git)\n  — why the kernel community wrote its own tool in 2005 and what it set out to\n  do.\n- [git-reflog](https://git-scm.com/docs/git-reflog) — how to find where a branch\n  pointed before the mistake, and how long that record lasts.\n- [git-push](https://git-scm.com/docs/git-push) — the force options, and what\n  each one protects.\n\n\u003chttps://engineer.company/glossary/git/\u003e\n","date_modified":"2026-11-08T02:22:23Z","description":"How git records a project as linked snapshots, why every clone carries the whole history, and the habits that leak secrets or overwrite a colleague's work.","formats":{"gemtext":"https://engineer.company/glossary/git/index.gmi","gopher":"https://engineer.company/glossary/git/gophermap","html":"https://engineer.company/glossary/git/","json":"https://engineer.company/glossary/git/index.json","markdown":"https://engineer.company/glossary/git/index.md","pdf":"https://engineer.company/glossary/git/index.pdf"},"kind":"page","language":"en","title":"What is git?","url":"https://engineer.company/glossary/git/","version":1}