Eight questions, eight answers. Each guide also appears in the lesson that teaches it; this page collects them so you can find one under pressure.
1. I changed a file, now what?
After any edit: status, then diff, then stage, then check the staged diff, then commit. Every "no" answer has a safe exit.
The everyday loop, in full, is lesson 5.9.
2. I want to undo something
Two questions decide almost everything: is it committed, and has it been pushed?
The full table of situations and commands is lesson 12.10.
3. I want the team's latest changes
Commit or stash first; fetch to look, pull to take.
Fetch and pull are compared in lesson 7.5.
4. Merge or rebase?
If anyone else has the branch, merge. If it is yours and the team wants a straight history, rebase.
Both are explained in lesson 6.7, and what each leaves on main is lesson 13.4.
5. Which authentication method?
You on your machine: an SSH key. A server or a script: a deploy key, or a scoped token with an expiry.
The detail is Section 8, and the platform pages are lesson 9.12 and lesson 10.12.
6. Which branch do I start from?
Production broken means a hotfix from the released tag. A develop branch means Git Flow. Otherwise, current main.
The four kinds of work are lesson 13.2, and the strategies are lesson 13.3.
7. My push was rejected
Four messages, four different answers. In every case, nothing was pushed.
Rejections in detail are lesson 7.6, and forcing safely is lesson 12.8.
8. Which undo rewrites history?
The left column is safe for other people; the right column is only for commits nobody else has.
The comparison is lesson 12.3, and the dangerous-commands list is lesson 12.9.
The two questions behind all of them
Almost every guide on this page reduces to one of two questions:
| Question |
Decides |
| Has this been pushed where other people can see it? |
Whether you may rewrite, or must add a commit |
| Is it committed? |
Whether Git can recover it at all |
If you remember nothing else from this page, remember those. Everything above is the detail of applying them.