Git and GitHubgit 2.54 · GitHub · macOS, Linux or Windows
Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
26 small wins to finish your pathNext lesson →

Writing a README

A README is the Markdown file GitHub shows on a repository's front page, and for most visitors it is the only part of the project they will read.

Last updated: 12 Oct, 2026 · git 2.54

Project repository structure put the files where a reader can find them. The README is the file that tells them what they are looking at and how to run it.

What goes in a README · from the Git and GitHub series · 1:54 to 2:52

The video goes through the sections one at a time: the project title, a short description, where the work came from, and what it is built with. The tool in the video is readme.so, a web page that offers the sections and writes the Markdown for you. The sections are the useful part, and you can type them by hand in any editor.

The one file every visitor reads. GitHub looks for a README in three places in order: .github/README.md first, README.md in the repository root next, and docs/README.md last; the root is where a reader expects it. The questions a README has to answer are what the project does, how to install it, which keys it expects, the one command to run it, and where the data comes from. A README is Markdown, with a hash for a heading, a dash for a list and triple backticks around a command. GitHub renders it on the repository's front page and builds a table of contents from the headings, and relative links to files in the repository keep working for anyone who clones it.

GitHub's docs are clear about the job: “A README should only contain information necessary for developers to get started using and contributing to your project”. They also name the three places GitHub looks, and which wins: the .github directory, then the repository's root directory, and finally the docs directory (About READMEs). The root is where people look, so that is where it goes.

Syntax: the whole of the Markdown a README needs.

text
# Project name          <- the big heading at the top
## A section            <- a smaller heading; GitHub builds a menu from these
- a list item
`one word of code`
[link text](https://example.com)
[the loader](src/loader.py)    <- a relative link, which works in a clone too

```
a block of commands
```

Answering the five questions

A short README that answers five questions beats a long one that answers none. What does this do, how do I install it, which keys does it want, what is the one command to run it, and where does the data come from.

The project the README has to describe

It is one script, one prompt, a sample note and a list of packages, in a throwaway repository. The two export lines stand in for the name and email you set once with git config --global, and fix the date so the hashes are the same on every run.

ExampleA project with no README yet
export GIT_AUTHOR_NAME=Reader GIT_AUTHOR_EMAIL=reader@example.com GIT_AUTHOR_DATE=2026-10-12T10:00:00
export GIT_COMMITTER_NAME=Reader GIT_COMMITTER_EMAIL=reader@example.com GIT_COMMITTER_DATE=2026-10-12T10:00:00
mkdir ask-docs && cd ask-docs && git init -q -b main
mkdir -p src data/sample
printf 'Answer only from the notes below.\n' > prompt.txt
printf 'A chunk is a slice of a document.\n' > data/sample/notes.txt
printf 'openai\npython-dotenv\n' > requirements.txt
git status --short

Three untracked paths, and nothing in them says what the project is for. That is the gap the README fills.

The command the README will promise

The script takes a question, puts the prompt and the notes in front of it and prints the result. Run it once before writing it down anywhere.

ExampleThe one command this project is for
cat > src/answer.py <<'PY'
import sys, pathlib
notes = pathlib.Path("data/sample/notes.txt").read_text()
prompt = pathlib.Path("prompt.txt").read_text()
print(prompt + notes + "\nQuestion: " + sys.argv[1])
PY
python3 src/answer.py "what is a chunk?"

That output is what the README's Run section is promising. Writing a command you have not run is how a README starts lying.

The title and the install section

The first heading is the repository's name and the line under it says what the project does. ## Install follows, with the commands indented by four spaces so Markdown shows them as a block.

bash
cat > README.md <<'MD'
# ask-docs

Answers a question from a folder of notes, using the prompt in `prompt.txt`.

## Install

    python3 -m venv venv && source venv/bin/activate
    pip install -r requirements.txt
MD

The keys and the run command

## Keys names the key and where to put it, with no value. ## Run is the single command from the example above.

bash
cat >> README.md <<'MD'

## Keys

Copy `.env.example` to `.env` and fill in `OPENAI_API_KEY`.

## Run

    python3 src/answer.py "what is a chunk?"
MD

Where the data comes from

The last section says what a reader has and what they do not, which is the honest version of a repository with a sample in it.

bash
cat >> README.md <<'MD'

## Data

`data/sample/` holds two notes so the command above runs. The full set of notes is
not in this repository.
MD

Committing the README and reading its headings

With the file written, one commit puts it in the repository, and the headings are worth a look on their own.

ExampleThe five questions, as five headings
git add . && git commit -q -m "Add a README that says how to run the project"
grep '^#' README.md
  • The title is the repository's name. A reader arriving from a search result sees the name and one sentence, and that is the whole decision about whether to read on.
  • Each heading is a question somebody has. GitHub turns these into a table of contents, so a long README stays navigable.
  • The indented blocks are commands. Four spaces makes a code block in Markdown; three backticks on their own line do the same and are more common.

Running the command the README gives

A README is a promise. The quickest way to break it is to write a command you have not run since the project changed. Run it in a fresh clone before you believe it.

ExampleA clone of only what was committed
git init --bare -q "$HOME/ask-docs.git"
git remote add origin "$HOME/ask-docs.git" && git push -q -u origin main
cd ~ && git clone -q "$HOME/ask-docs.git" fresh && cd fresh
ls

The bare repository stands in for the one on GitHub, and the clone holds what a reader would get: five paths, the README among them.

ExampleThe README's run command, in the clone
python3 src/answer.py "what is a chunk?"

The same output, in a folder that holds only the commits. If the command needed a file that .gitignore kept out, it would fail here and not on your machine, which is the mistake this catches.

What belongs in which section

SectionThe question it answersWhat goes wrong without it
Title and one linewhat is this?a reader leaves without knowing
Installwhat do I install?a wall of import errors
Keyswhat do I need an account for?it runs and fails on the first call
Runwhat is the one command?a reader guesses, and guesses wrong
Datawhere do the files come from?an empty folder and no idea what fills it
Licencemay I use this?nobody can, legally

Where the README does the work

  • A recruiter or a reviewer. They open two or three of your repositories and read the front page of each. That page is this file.
  • Yourself after a break. The install line and the run line are the two things you never remember.
  • Anyone who wants to help. A project that cannot be run cannot be contributed to, so the install and run sections are what make a pull request possible.
Watch out. Keep secrets out of the README too. Example commands with a real key, a database URL with a password in it, or an internal address all get committed and pushed with everything else. Write OPENAI_API_KEY=your-key-here and let the reader fill it in.
Try it yourself
  • Add a ## Licence section and a LICENSE file, then link to it from the README with a relative link, [the licence](LICENSE).
  • Break the run command, clone the repository into a new folder and run it there. The clone is where a broken README shows itself.
  • Open one of your own repositories and count how many of the five questions its README answers.

Slow is fine. Stopping is the only problem.