GIT & VERSION CONTROL · REFERENCE
Quick Reference and Vocabulary
Look up a command or symptom, then return to the full lesson before using an unfamiliar operation.
At a glance
| Term or command | What it means | When to use it |
|---|---|---|
| Inspect | git status; git diff; git diff --staged | Use before adding or committing. |
| Record | git add FILE; git commit -m "message" | Select and record a meaningful change. |
| Read history | git log --oneline; git show HEAD | Understand an existing version. |
| Branch | git switch -c NAME; git switch main | Develop separately or return to main. |
| Remote | git remote -v; git fetch origin | Check addresses and download remote history. |
| Synchronize | git pull --ff-only; git push | Use with an established upstream and understood branch state. |
| Unstage | git restore --staged FILE | Keep edits while removing the staging selection. |
| Reverse a commit | git revert COMMIT | Create a new reversing commit; inspect the intended target first. |
Commands are examples, not an interactive terminal. Run them in your own learning repository after checking the prerequisites. Output, paths, commit IDs, and wording can vary. Host-specific instructions are labeled.
Vocabulary without the guesswork
| Term or command | What it means | When to use it |
|---|---|---|
| Index | Another name for the staging area. | Holds selected content for the next commit. |
| HEAD | Usually the current branch’s tip commit. | Read history relative to the current position. |
| Upstream branch | The branch your local branch is configured to track. | Used by ordinary pull/push behavior; check with git branch -vv. |
| origin/main | Your local remote-tracking reference for origin’s main. | Updated through communication such as fetch, not a live view of the server. |
| Fork | A host-side copy related to another repository. | Propose contributions without direct write access. |
| Clone | A local copy of an existing repository. | Obtain files and Git history. |
| Merge conflict | A combination Git needs you to resolve. | Make an intentional final edit, then complete the operation. |
| Remote | Another repository location with a nickname. | Can be a host URL, server, or local path. |
Read short status
?? notes.txt untracked
M index.html changed in working tree
M index.html staged modification
MM index.html staged, then edited again
UU index.html unresolved merge conflict
The two status columns matter. The diagram adds explanatory text after filenames; that explanation is not part of Git’s actual output.
Common messages and next steps
| Message | Likely meaning | Next step |
|---|---|---|
| Not a git repository | You may be outside the repository folder. | Change into the correct project. Do not initialize a new repository merely to silence the message. |
| Nothing to commit | No staged changes to record. | Use status; check whether edits were saved and added. |
| No upstream branch | Git needs a tracking destination. | After checking your remote and branch, use git push -u origin BRANCH with the real branch name. |
| Authentication failed | Credentials or access may be missing. | Use the chosen host’s supported authentication and verify repository permissions. |
| Non-fast-forward rejection | The remote branch has history your push would overwrite. | Fetch and inspect. Integrate deliberately; do not immediately force-push. |
| Conflicting files | Git needs a resolved final version. | Follow Fixing Mistakes and check which operation is in progress. |
Where should I run these?
Open a terminal inside the repository’s project folder. FILE, NAME, BRANCH, COMMIT, and URL are placeholders in this reference; replace them, and do not type angle brackets around real values. A command shown alone does not imply all commands on this page should run in sequence.
An ordinary daily sequence
git status
git diff
git add index.html
git diff --staged
git commit -m "Explain the change"
git push
Push here assumes your branch already tracks the intended remote. Test the actual project before recording and sharing the change. A separate branch and a review request may be required by your team.
Sources and further reading
Study questions
Explain it in your own words, then open the answer.
Is origin/main a live server connection?
No. It is local remote-tracking information, updated by operations such as fetch.
What does MM indicate?
A tracked file has staged changes and additional unstaged changes.
What should I do before using an unfamiliar recovery command?
Read its full lesson, inspect status and diffs, and understand which content it can overwrite.
Should I type FILE literally?
No. It is a placeholder for a real filename.
Does this guide require GitHub?
No. Local Git works independently, and remotes can use many hosts.