Repository vs commit vs branch vs staged change
Verdict: A repository is the whole project plus its revision history. A commit is one snapshot. A branch is a line of development. A staged change is waiting for the next commit.
| Criterion | Repository | Commit | Branch | Staged change |
|---|---|---|---|---|
| Definition | The entire collection of a project's files and folders plus each file's revision history | A single snapshot in the project's history | One of multiple lines of development commits are organised into | A change added with git add, waiting for the next commit |
| Scope | Whole project and history | One point in time | A strand of development | Not yet committed |
Rules
- A repository encompasses the entire collection of a project's files and folders along with each file's revision history.
- A branch is one of multiple lines of development into which a repository's commits can be organised.
- git merge combines lines of development, typically bringing a feature branch's changes into the main branch.
Traps
- A commit is one snapshot in history, not the whole repository.
- A staged change made with git add is waiting to be committed and is not yet part of the repository's history.