Skip to content
general version-control

Git

git version-control source-code collaboration
Plain English

Git is a time machine for your code. Every time you save a checkpoint (commit), Git records exactly what changed, when, and who made the change. You can go back to any previous version, see the entire history of a file, and work on new features in parallel without affecting the main codebase. When multiple people work on the same project, Git merges their changes together intelligently. It is the universal tool that every developer uses daily.

Technical Definition

Git is a distributed version control system (DVCS) created by Linus Torvalds in 2005 for Linux kernel development. Unlike centralized systems (SVN, Perforce), every developer has a complete copy of the repository including full history.

Core concepts:

  • Repository: a directory tracked by Git, containing the working tree, staging area (index), and object database (.git/)
  • Commit: an immutable snapshot of all tracked files at a point in time, identified by a SHA-1 hash. Contains a pointer to its parent commit(s), forming a directed acyclic graph (DAG).
  • Branch: a lightweight, movable pointer to a commit. The default branch is main (formerly master).
  • HEAD: pointer to the current branch/commit
  • Remote: a copy of the repository on another machine (e.g., GitHub, GitLab)
  • Merge: combines changes from two branches. Fast-forward (linear) or three-way merge (diverged branches).
  • Rebase: replays commits from one branch onto another, creating a linear history

Git objects (content-addressable storage):

  • Blob: file contents (no filename, just data)
  • Tree: directory listing mapping filenames to blob hashes
  • Commit: points to a tree, parent commit(s), author, message
  • Tag: named reference to a specific commit

Branching strategies:

  • Trunk-based: short-lived feature branches merged frequently to main
  • Git Flow: develop, feature, release, hotfix branches (heavier process)
  • GitHub Flow: main + feature branches with pull requests

Essential Git workflow

# Initialize and configure
$ git init
$ git config user.name "Mokey"
$ git config user.email "mokey@bytesnation.com"

# Daily workflow
$ git status                    # What's changed?
$ git diff                      # See exact changes
$ git add src/server.ts         # Stage specific files
$ git commit -m "feat: add health check endpoint"

# Branching
$ git checkout -b feat/vlan-api # Create and switch to new branch
# ... make changes ...
$ git commit -m "feat: add VLAN management endpoint"
$ git checkout main
$ git merge feat/vlan-api       # Merge feature into main

# Remote operations
$ git remote add origin git@github.com:user/repo.git
$ git push -u origin main      # Push to remote
$ git pull origin main          # Fetch and merge remote changes

# History inspection
$ git log --oneline --graph -10
* a1b2c3d feat: add VLAN management endpoint
* d4e5f6g fix: resolve DNS timeout in health check
* g7h8i9j refactor: extract subnet calculator
In the Wild

Git is the backbone of modern software development. GitHub hosts over 400 million repositories, and virtually every open-source project and professional team uses Git. Beyond code, Git tracks infrastructure configurations (GitOps), documentation, and even this website’s content (blog posts are Markdown files in a Git repository). The Git workflow (branch, commit, push, pull request, review, merge) is the standard collaboration pattern. Git hooks (pre-commit, pre-push) enable automated checks before code enters the repository. Understanding Git is a prerequisite for any technical role; it is the first tool a new developer learns and the last tool a senior engineer stops optimizing.

Related Terms