Files plus history
A repository is the unit that holds a project’s files and its change history together, often shortened to repo. For a website, the HTML, CSS, image references, and the record of every change all live in one repository.
It resembles an ordinary folder, but a Git repository also carries the information that tracks history and branches. Once Git is initialized, a normally hidden .git directory appears inside the project folder.
Local and remote
The copy on your machine is the local repository; the one on GitHub or a similar service is the remote. Commits are recorded locally first, and pushing sends that history to the remote.
The two are not always identical. You may have unsent commits, and someone else may have pushed changes you have not pulled.
Folder, repository, GitHub
- Folder: a container for organizing files
- Repository: the unit that manages files together with Git history
- GitHub: a service for hosting and sharing remote repositories
What belongs in one repository
As a rule, one project that is changed and released together belongs in one repository. Packing unrelated sites into a single repository makes both history and permissions hard to follow.
Generated files, large video, and passwords are excluded with .gitignore. Note that adding a secret to .gitignore after it has already been committed does not remove it from the history.
A monorepo — several related projects in one repository — is a valid pattern, but while you are learning, one site per repository makes the structure easier to grasp. Decide based on how far you want release units, permissions, and history to be shared.