Files
guide/en/08-commits-and-history/readme.md
T

47 lines
2.0 KiB
Markdown
Raw Normal View History

# 08 — Commits and history
🌍 **English** · [Türkçe](../../tr/08-commits-and-history/readme.md) · [Deutsch](../../de/08-commits-and-history/readme.md) · [Français](../../fr/08-commits-and-history/readme.md) · [Русский](../../ru/08-commits-and-history/readme.md)
A commit is one saved step: what changed, who changed it, when, and why.
## Writing a good message
```
add VLAN configuration notes
fix wrong gateway address in readme
remove unused packet capture
```
- One line, present tense, no full stop.
- Say *what* the change does, not "update" or "fix stuff".
- Longer explanation? Put it in the description box below the summary.
## Committing well
- **One idea per commit.** Two unrelated changes are two commits.
- **Commit often.** Small steps are easy to review and easy to undo.
- **Never commit passwords, keys or tokens.** Removing them later does not remove them from history — you have to change the secret itself.
## Reading history
| Where | What you get |
|-------|--------------|
| **History** button on a folder or file | Every commit that touched it |
| A commit's page | The full diff: red removed, green added |
| **Blame** on a file | Which commit last changed each line |
| **Activity** tab | Contribution graph over time |
## Undoing
- **One commit was wrong** → open the commit, press **Revert**. This creates a new commit that undoes it; nothing is erased.
- **A file was wrong** → open its history, view the good version, copy the content back and commit.
- **A commit is not pushed yet** (working from your computer) → `git commit --amend` to fix the last one before sharing it.
## Comparing
Add `/compare/main...my-branch` to a repository URL, or use the **Compare** button, to see every difference between two branches or tags.
---
⬅ [Previous: 07 — Images and attachments](../07-images-and-media/readme.md) · 📚 [Contents](../README.md) · [Next: 09 — Branches and pull requests](../09-branches-and-pull-requests/readme.md) ➡