Git Basics

8

questions

How does a distributed VCS differ from a centralized one?

In a centralized VCS (SVN), history is stored on a single server: without a connection to it, you can't commit or view history. In a distributed VCS (Git), every clone is a full copy of the repository with its entire history. That's why most operations are local and fast, and losing the server doesn't mean losing the history.

How is Git different from GitHub?

Git is a version control system that runs locally on your computer. GitHub is a cloud service that hosts Git repositories and adds team tools: pull requests, code review, issues, GitHub Actions. Git works without GitHub; alternatives to GitHub include GitLab and Bitbucket.

What does Git store: snapshots or diffs?

Snapshots. Every commit is a snapshot of the state of all project files; unchanged files aren't copied but point to the already stored version. Git computes diffs on the fly when you ask for them. Delta compression in pack files is just an on-disk storage detail, not the data model.

What states can a file have in Git?

Untracked — Git doesn't track the file yet. A tracked file can be unmodified (matches the last commit), modified (changed but not added) or staged (added to the staging area). After git commit, staged changes go into the repository and the file is unmodified again.

What's the difference between git init and git clone?

git init creates a new empty repository in the current folder. git clone <url> copies an existing repository with its entire history and branches and sets up the origin remote right away.

Where is Git configuration stored?

At three levels: --system — for all users on the machine (/etc/gitconfig), --global — for your user (~/.gitconfig), --local — for one repository (.git/config). The closer level overrides the farther one: local → global → system. To see everything with its source: git config --list --show-origin.

Why do you need the staging area?

To build the next commit deliberately: add only part of your changes (even part of a file with git add -p) and leave the rest for later. That keeps commits small and logical.

Why does a WordPress developer need Git if wordpress.org uses SVN?

SVN on wordpress.org is only the release channel for a plugin. The actual development, team work, code review and CI happen in Git (mostly on GitHub), and deploying to SVN is automated, for example with GitHub Actions.