Git: Snapshots of Your Project
You tweak Sprout's plant list, it breaks, and you cannot remember what it looked like an hour ago. Git fixes that by keeping a history of snapshots you can inspect, compare and return to. It also becomes the way you share Sprout with anyone else.
The rule
Edit in the folder, choose with
add, save withcommit.
A change passes through three places:
| Place | What it holds | Command that moves it on |
|---|---|---|
| Working folder | Files as you are editing them | git add |
| Staging area | Changes chosen for the next snapshot | git commit |
| History | Saved snapshots (commits) | — |
git init # once: start tracking this folder
git status # what changed, what is staged
git add lib/plant_tile.dart # stage one file
git commit -m "Show days left under each plant"
git log --oneline # list the commits- A commit is a snapshot of every tracked file, plus a message, author and time. Each has an ID such as
a1b2c3d. flutter creategives you a sensible.gitignore, but it does not start a repository. Rungit inityourself (many editors offer a button for it).- Write messages that say what the change does: "Show days left under each plant", not "stuff".