Dualo
Git & GitHub

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.

1 min read

A commit is an immutable object containing: a tree SHA (root of the snapshot), one or more parent SHAs (zero for the root commit, two+ for merges), author + committer (name, email, timestamp), and the commit message. Hash = SHA-1 of the serialized object.

git commit flags: -m "msg" (message inline), -a (auto-stage modified tracked files, skips new ones), --amend (replace the previous commit — dangerous if pushed), -S (GPG-sign), --allow-empty (commit with no changes, useful for triggering CI), --fixup <sha> (marker commit for later interactive rebase).

Author vs committer: usually identical. They differ when a commit is rewritten (rebase, amend) or applied via git am. The author is who wrote the change; the committer is who put it in this branch. git log --format=full shows both.

Conventional commits: a popular convention encoding type+scope in the subject — feat(auth): add Google SSO, fix: handle null callback URL, refactor(db): extract query helper. Tools like commitlint, semantic-release, and changesets parse this format to automate versioning.

Atomic commits: a single commit should encapsulate one logical change. Easier to review, easier to revert (git revert <sha> undoes one commit cleanly), easier to bisect when hunting bugs (git bisect). The staging area is what makes atomic commits practical.

Referencing commits: full SHA, short SHA (≥4 chars, must be unambiguous), HEAD, HEAD~N (Nth ancestor via first parent), HEAD^N (Nth parent of HEAD — relevant for merges), branch@{N} (Nth previous position), :/regex (search log message). git rev-parse <ref> resolves any of these to a full SHA.

Practice

Type the command to commit your staged changes with the message "Add login form".

Practice

Type the shortcut to stage all *modified tracked* files AND commit with message "Fix typo".

Grounded on https://git-scm.com/docs/git-commit

Next up

.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.