Skip to content
IROSG.
Articles

How Git works internally: objects, commits, refs, HEAD and reflog

An original source-backed IROSG IT guide.

How Git works internally: objects, commits, refs, HEAD and reflog

Scope

This original IROSG guide covers مدل دادهٔ content-addressed در Git using the cited primary documentation.

Core model

Git repository را می‌توان graphی از objectهای immutable دید. Blob محتوا، Tree ساختار مسیر و Commit اشاره به Tree و parent دارد. Branch در اصل یک ref متحرک به commit است و HEAD موقعیت فعلی را توصیف می‌کند.

Practical workflow

git cat-file، rev-parse و log --graph کمک می‌کنند abstraction را کنار بزنید. وقتی بدانید branch فقط یک ref است، reset، rebase و detached HEAD قابل فهم‌تر می‌شوند.

Failure modes

اشتباه رایج این است که reset یا rebase را «حذف جادویی فایل» ببینیم. در بسیاری از سناریوها object هنوز وجود دارد و reflog مسیر بازیابی را نگه می‌دارد؛ اما garbage collection و گذر زمان این فرصت را دائمی نمی‌کنند.

Lab

یک repository کوچک بسازید، چند commit ایجاد کنید، hashهای blob/tree/commit را با cat-file بررسی کنید، branch را جابه‌جا کنید و یک commit را عمداً گم کنید؛ سپس با reflog بازیابی کنید.

Production method

Capture a baseline, change one variable at a time, test positive and negative paths, keep evidence, and rehearse rollback before broad rollout.

TRACEABLE KNOWLEDGE

Sources & further reading

01
Git — مرجع فنیhttps://git-scm.com/book/en/v2/Git-Internals-Git-Objects

Editorial review date:

IROSG / EDITORIAL

News and pioneer profiles use original writing with source attribution. Image credits and licenses are kept in each page’s sources section instead of beneath the images. CVE reference data credits its primary sources.

Editorial and image policy ↗

Keep exploring.

Articles ↗
VyOS network operating systemArticles
Networking

VyOS network operating system

Original Persian technical editorial based on the official sources below. It covers the subject, architecture, practical use cases, important limitations and defensive considerations.

1 min readRead story
Routinator RPKI validatorArticles
Networking

Routinator RPKI validator

Original Persian technical editorial based on the official sources below. It covers the subject, architecture, practical use cases, important limitations and defensive considerations.

1 min readRead story
ISC Kea DHCP High AvailabilityArticles
Networking

ISC Kea DHCP High Availability

Original Persian technical editorial based on the official sources below. It covers the subject, architecture, practical use cases, important limitations and defensive considerations.

1 min readRead story