Git & GitHub
From your first commit to clean PRs and conflict resolution: the 10 concepts that turn Git from a black box into a tool you actually control — staging, branches, merge vs rebase, remotes, and collaboration.
What is Git?
A distributed version control system. It tracks every change to your code, lets you experiment safely, and enables multiple people to work on the same project without stepping on each other.
Initialize a repository
`git init` turns any folder into a Git repository. A hidden `.git/` directory appears — that's where the entire history lives.
The three trees: working, staging, repository
Git has three areas: the files you edit (working tree), the changes you've prepared (staging), and the committed history (repository). Every Git command moves data between these.
Your first commit
A commit is a snapshot with a message. You stage what you want, then commit with a description of *why* you made the change. That message is the gift you give to your future self.
.gitignore — files Git should ignore
A plain-text file at your repo root listing patterns Git won't track: `node_modules/`, `.env`, build artifacts. Without it your repo bloats with noise.
Branches — parallel timelines
A branch is a named pointer to a commit. Cheap to create, cheap to delete. You branch off `main` to work on a feature, then merge back when done.
Merge vs rebase
Two ways to integrate changes from one branch into another. Merge preserves history as it happened (with a merge commit). Rebase rewrites your branch on top of another, producing a linear history.
Resolving merge conflicts
Two branches changed the same lines? Git pauses, marks the conflict in the file, and waits for you to choose. Edit, stage, continue.
Remotes — push and pull
A remote is another Git repo, usually on a server. `push` uploads your commits, `pull` downloads theirs. `origin` is the conventional name of the main remote.
Pull Requests on GitHub
A PR is a proposal to merge your branch into another. GitHub shows the diff, runs CI, and lets reviewers comment line-by-line before approving.