Memory hook: Commit locally, share remotely, review before merging.
Must remember
Git is a distributed version-control system. GitHub hosts repositories and adds collaboration, automation and governance. A local repository can have commits that have never been pushed anywhere. A commit records a snapshot and metadata; a branch is a movable reference to a line of development.
The working tree contains files being edited. Staging selects changes for the next commit. git status shows the relationship between working tree, index and branch; git diff inspects changes. git add stages, git commit records locally and git push transfers commits to a remote. git fetch retrieves remote history without integrating it into your current branch; pull retrieves and integrates according to configuration.
GitHub Flow uses a short-lived branch, focused changes, a pull request, review/checks and merge. Keep the default branch usable and remove obsolete branches after their work is integrated. A pull request proposes integration between branches; it is not the same operation as git pull.
Merging joins histories; rebasing replays commits onto a new base and changes commit identities. Conflicts require understanding both intended changes, resolving files and verifying the result. Rewriting shared history can disrupt collaborators, so follow repository policy. A revert records an inverse change; deleting a file in a new commit does not erase it from older history.
Personal accounts represent individuals; organizations organize shared repositories, teams and policies; enterprises coordinate eligible organizations and enterprise settings. Keep individual attribution and use scoped access rather than shared human credentials.
Choose under exam pressure
| Requirement | Choice and reason |
|---|---|
| Inspect remote changes without integrating | Fetch, then compare. |
| Propose a reviewed change | Branch and pull request. |
| Undo a published change while preserving history | A reviewed revert where appropriate. |
Traps
- Commit does not mean push.
- Removing a secret from the latest file does not remove it from history or revoke it.
Active recall
1. Git versus GitHub?
Distributed version control versus a hosting/collaboration platform built around it.
2. What is staged?
The selected content intended for the next commit.
3. Fetch versus pull?
Retrieve remote history versus retrieve and integrate it.
4. What is a branch?
A reference to a line of commits, not a separate full copy of the repository.
5. Why review a conflict resolution?
A syntactically valid merge can still discard intended behavior.