git.guide

Git, for people who have a live website to worry about

Nine guides. They assume you can already commit and push, and that what you actually want to know is what happens when something goes wrong, what is safe to do on a branch other people are using, and what any of it costs you when it reaches a server.

No sign up, no newsletter, no video. If a page does not answer your question in the first paragraph, it has failed and you should leave.

Keeping your repository off the web

The leak this site checks for, and the three things that stop it happening again.

What an exposed repository gives away

Every version of every file, including the secrets you took out again.

How to block it

The rule for Apache, nginx, Caddy, LiteSpeed, IIS and Cloudflare.

Deploying without publishing the repository

Three ways to get code onto a server that cannot leak like this.

A password is in your history

Why changing it is the fix and rewriting history is not.

Getting yourself out of trouble

The pages people arrive at in a hurry, with the safe answer before the clever one.

Undoing almost anything

One table, from unstaging a file to recovering a commit you deleted.

Why your ignore file is not working

Because it does nothing about a file git has already been told to track.

A repository that has got too big

What one committed database dump costs, and how long it keeps costing it.

Working with other people

Branches, remotes, and the errors that stop a deploy at five to five on a Friday.

Branches, merging and rebasing

What a branch actually is, and the one rule you must not break.

Pushing, pulling and the errors you will hit

Rejected pushes, force with lease, and how to leave a detached HEAD.

Why this exists

Written by somebody who has to clean up afterwards.

Most git writing is by people teaching git. This is by somebody who runs other people's production systems and meets git at the point where it has already gone wrong: the repository being served to the public, the password in a commit from two years ago, the deploy that pulled the wrong branch at half past four on a Friday.

So the bias throughout is towards the safe answer before the clever one, towards saying which commands rewrite history and which do not, and towards being clear about what cannot be undone.

git.guide is run by Dalaric. Hosting, domains, email and databases since 1996. Websites are the small part.