Git is a free program that keeps a full history of every change made to a project's files. Developers use it to save snapshots of their work, go back to any earlier state, and combine changes made by several people without overwriting each other. It runs on your own computer and works without an internet connection.
How Git tracks a project
Git watches a folder you choose. When you are happy with a set of edits, you record them as a commit: a snapshot of the files plus a message explaining what changed and who changed it. Each commit points back to the one before it, so the project becomes a chain of snapshots you can step through. Git identifies every commit by a long hash, a fingerprint computed from its contents, which is why history cannot be quietly altered without the hashes changing.
Branches let you split off a separate line of work. You might create a branch called new-menu, experiment freely, and only merge it into the main branch once it works. If two people edit the same lines, Git stops and asks a person to settle the conflict rather than guessing.
Git is distributed: every copy of the project, called a clone, holds the complete history. If a laptop dies, any other clone can restore everything.
Where Git came from
Linus Torvalds wrote Git in 2005 to manage the Linux kernel after the project lost access to its previous tool, BitKeeper. It is now the dominant system for version control in software. Git itself is only the command-line tool; services such as GitHub, GitLab and Bitbucket host Git projects online and add features like code review on top.
Does a small business owner need to know Git?
If you never touch your site's code, you can mostly ignore it, but it is worth knowing whether your developer uses it. A site kept in Git can be rolled back to last Tuesday's version in minutes after a bad change, and a new developer can pick up the full history instead of a zip file. If you hire someone, ask where the Git repository lives and make sure your business account owns it. Some builders, including We.Inc, let you export a site's code to GitHub, which puts it under Git from day one.
Mistakes people make with Git
- Committing passwords and API keys. Once a secret is in history, deleting the file does not remove it. Rotate the key and keep secrets in environment variables.
- Vague messages like "fix" or "stuff". Six months later nobody can tell which commit broke the checkout page.
- Working for weeks without committing. Small, frequent commits make it easy to find and undo a single bad change.
- Force-pushing over shared history. Rewriting a branch other people use can silently throw away their work.
Related terms
- GitHub: the most popular website for hosting Git projects.
- Repository: the project folder plus its Git history.
- Commit: a single saved snapshot in Git.
- Pull request: how changes on a branch get reviewed before merging.