By admin , 28 April 2026

Introduction

Git is split into two layers. Plumbing commands are low-level building blocks operating on the object database, refs, and the index. Porcelain commands are user-friendly wrappers built from plumbing. git commit is porcelain; git hash-object, git write-tree, and git update-ref are plumbing.

By admin , 28 April 2026

Introduction

Garbage collection (gc) keeps your repository compact and fast. Git runs it automatically when certain thresholds are exceeded. You can also invoke it manually.

By admin , 28 April 2026

Introduction

A shallow clone downloads only the most recent N commits of a branch instead of the full history. The result is much smaller and faster to fetch, at the cost of an incomplete history.

Creating

git clone --depth 1 https://github.com/example/widget.git
git clone --depth 50 https://github.com/example/widget.git
git clone --depth 1 --branch v1.2.3 --single-branch <url>

The .git directory contains a shallow file listing commits whose parents have been omitted.

By admin , 28 April 2026

Introduction

Authenticating to a Git remote is mostly invisible until it goes wrong. The two main mechanisms are SSH keys and HTTPS credentials (passwords or, more commonly today, personal access tokens).

SSH keys

Generate a modern key:

ssh-keygen -t ed25519 -C "[email protected]"
ssh-add --apple-use-keychain ~/.ssh/id_ed25519     # macOS
ssh-add ~/.ssh/id_ed25519                           # Linux

Add the public key (~/.ssh/id_ed25519.pub) to your hosting account. Test:

By admin , 28 April 2026

Introduction

Git can transport data over four families of protocols. Each has different trade-offs in performance, authentication, and firewall friendliness.

Local / file

Cloning from a directory uses local file I/O. Two URL forms:

git clone /srv/git/widget.git
git clone file:///srv/git/widget.git

The first form may use hardlinks for objects when on the same filesystem (very fast, very space-efficient). The file:// form always copies via the smart protocol.

By admin , 28 April 2026

Introduction

Everything Git knows about a repository lives in .git/. Knowing what each entry is removes the mystery from "what just happened?" diagnostics.

By admin , 28 April 2026

Introduction

Git's content-addressed model deduplicates identical objects, but similar-but-not-identical blobs (a file and its later edit) would still cost full size each. Pack files solve this with delta compression: store one object as a base plus a sequence of "copy/insert" instructions that produce another object.

How it works

When packing, Git compares candidate objects (typically blobs of similar size and type) and chooses a base for each. The delta records:

By admin , 28 April 2026

Introduction

Git stores objects in two physical formats. Loose objects are individual files; packed objects live inside a pack file with a delta-compressed body. Both forms describe the same logical objects, addressed by the same hashes.

Loose layout

Each loose object is at .git/objects/xx/yyy..., where xx is the first two hex chars of the SHA and yyy... is the remaining 38. The file is the zlib-deflated bytes of <type> <size>\0<content>:

By admin , 28 April 2026

Introduction

A symbolic ref is a reference whose value is another ref name rather than an object hash. The canonical example is HEAD, which usually contains ref: refs/heads/main. Symbolic refs let Git track "the current branch" as data, not state.

By admin , 28 April 2026

Introduction

"Reachability" is the most important property of a Git object. An object is reachable if some ref leads to it via parent or tree links. Unreachable objects are eligible for garbage collection.

Reachability rules

Starting from any ref: