Glossary Development

Git

Git is a distributed version control system that records snapshots of a project's files so you can track changes, go back and collaborate.

Last reviewed:

AdSense Placeholder
Slot: header_reference_page

In more detail

Linus Torvalds created Git in 2005 for the Linux kernel. Every copy (clone) holds the whole history, work happens on cheap branches and is combined by merging or rebasing. Services such as GitHub and GitLab host shared repositories. See Git Cheat Sheet. Internally Git is a content-addressed store: every file version (blob), directory (tree) and commit is named by a hash of its content, so any change to history changes the IDs that follow. Changes move through three places: the working directory, the staging area (git add) and the repository (git commit).

Why it matters

Version control lets you see exactly what changed, when and why, undo mistakes and work in parallel without overwriting each other. The usual pitfalls are committing secrets (they stay in history even after deletion, so rotate them), committing build output or large binaries, and rewriting history that others have already pulled. A .gitignore file keeps unwanted files out.

Example

A branch, a commit and a fast-forward merge in a fresh repository:

$ git switch -c fix-typo
$ sed -i 's/line two/line 2/' notes.txt
$ git commit -am "Use digit"
$ git diff main --stat
 notes.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
$ git switch main && git merge fix-typo

Object IDs are hashes of content: echo 'hello' | git hash-object --stdin always prints ce013625030ba8dba906f756967f9e9ca394464a, the SHA-1 of blob 6\0hello\n. Start a project's ignore list with the .gitignore Generator.

Common confusion

Git is the tool; GitHub, GitLab and similar sites are hosting services built around it. You can use Git entirely offline without any of them.

AdSense Placeholder
Slot: footer_leaderboard