Git Fundamentals
Git is a distributed version control system that tracks changes to source code across branches, enabling multiple developers to work concurrently and merge their history. It stores snapshots of a project's files, provides cheap branching, and operates fully offline.
itDevOps and software delivery | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic — Git Fundamentals
Git is a distributed version control system. That means a clone is not a polite request to borrow some files from a server. It is a local copy of a project's reachable history, plus the names that make the history navigable. The server is useful, certainly. It is also not a small glowing orb containing the only copy of reality.
The useful picture has four places. The working tree is the file set you edit. The index, also called the staging area, is the exact content proposed for the next commit. HEAD is the commit currently checked out. Remote-tracking references, such as origin/main, are your local record of what a remote said when you last fetched. Most Git confusion is two of these places wearing the same hat.
A commit records a snapshot and its parent relationship. A branch is a movable name for a commit, not a spare directory that wandered off to start its own life. git add copies selected file content to the index. git commit records that proposed snapshot locally and advances the current branch. That sequence is why a commit is not a cloud upload, despite its surprisingly confident posture.
When histories meet, choose the promise you need. Merge combines histories and can preserve both parents. Rebase reapplies commits on a new base, creating replacement commits with new identities. That can make private work easier to read. It becomes a coordination problem when other people already depend on the old identities. Conflicts are Git declining to invent intent, which is irritating but considerably less irritating than it doing so.
Remotes remain a separate decision. Fetch updates remote-tracking references without integrating them. Pull fetches and then integrates. Push asks a remote to move a reference. A rejected push is a signal to inspect what the remote knows, not an invitation to make the error message disappear.
Read the Intro for the full state model and recovery boundaries. Use Slides when you need the relationships at a glance, Cheatsheet for command-to-layer mappings, and the practice session to make the graph, index, and branch names visible in a disposable repository. The quiz checks whether the words have stopped pretending to be interchangeable.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://git-scm.com/docs/gitdatamodel
Supports
- Objects, references, index, and reflogs as the core data model
- Commit, tree, blob, branch, HEAD, and remote-tracking-reference semantics
- Commits point to trees and parent commits; displayed diffs are calculated
- Reflogs are local, can aid recovery, and do not retain entries forever
- https://git-scm.com/book/en/v2/Getting-Started-What-is-Git
Supports
- Snapshot-oriented model and local operation
- Tracked, modified, and staged states
- Integrity and recoverability framing
- https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository
Supports
- Working-tree, staging, diff, and commit loop
- Tracked and untracked file states
- https://git-scm.com/docs/giteveryday
Supports
- Representative everyday status, diff, add, commit, switch, merge, and log usage
- https://git-scm.com/docs/git-switch
Supports
- Branch creation and switching semantics
- Index and working-tree updates and protection against loss of local changes
- https://git-scm.com/docs/git-merge
Supports
- Merge, fast-forward, conflict, continuation, and abort behavior
- https://git-scm.com/docs/git-rebase
Supports
- Reapplication of commits on a new base and replacement commit identities
- https://git-scm.com/docs/git-fetch
Supports
- Object download and remote-tracking reference updates without current-branch integration
- https://git-scm.com/docs/git-pull
Supports
- Pull as fetch followed by integration using merge or rebase
- https://git-scm.com/docs/git-push
Supports
- Remote reference update semantics, rejection, force, and force-with-lease behavior
- https://git-scm.com/docs/git-restore
Supports
- Working-tree restoration and index restoration with --staged
- Destructive consequences of intentionally discarding local content
- https://git-scm.com/docs/git-reset
Supports
- Soft, mixed, and hard reset effects on branch, index, and working tree
- https://git-scm.com/docs/git-revert
Supports
- Recording a new commit that reverses an earlier commit
- https://git-scm.com/docs/git-reflog
Supports
- Viewing and managing local reference logs for inspection and recovery
- https://git-scm.com/book/en/v2/Getting-Started-A-Short-History-of-Git
Supports
- Git began in 2005 for Linux kernel development
- https://github.com/git/git/blob/master/Documentation/RelNotes/1.0.0.txt
Supports
- Git 1.0 release milestone
- https://github.com/git/git/blob/master/Documentation/RelNotes/1.7.0.txt
Supports
- Git notes support in Git 1.7.0
- https://github.com/git/git/blob/master/Documentation/RelNotes/2.0.0.txt
Supports
- Safer default push behavior in Git 2.0
- https://github.com/git-lfs/git-lfs/releases/tag/v1.0.0
Supports
- Git LFS 1.0.0 release and pointer-based large-file storage
- https://github.com/git/git/blob/master/Documentation/RelNotes/2.18.0.txt
Supports
- Partial clone support in Git 2.18
- https://github.com/git/git/blob/master/Documentation/RelNotes/2.23.0.adoc
Supports
- Introduction of git switch and git restore
- https://github.com/git/git/blob/master/Documentation/RelNotes/2.28.0.txt
Supports
- Configurable initial branch name in Git 2.28
- https://github.com/git/git/blob/master/Documentation/RelNotes/2.38.0.txt
Supports
- Scalar included for large repository workflows in Git 2.38
- https://docs.github.com/en/get-started/using-git/about-git
Supports
- GitHub hosting complements local Git repositories
- https://docs.gitlab.com/user/project/repository/
Supports
- GitLab project repository and branch workflows
- https://learn.microsoft.com/en-us/azure/devops/repos/get-started/what-is-repos?view=azure-devops
Supports
- Azure Repos provides Git repositories and pull-request collaboration
- https://docs.gitea.com/installation/
Supports
- Gitea can be installed as self-hosted Git collaboration infrastructure
- https://github.blog/engineering/engineering-principles/how-github-uses-merge-queue-to-ship-hundreds-of-changes-every-day/
Supports
- Large pull-request trains created wait and failure costs at GitHub
- A merge queue became the integration process for high-volume changes
- https://about.gitlab.com/blog/postmortem-of-database-outage-of-january-31/
Supports
- Git repository copies contributed to restoration after destructive changes
