{"course":{"slug":"building-apps-with-ai","title":"Building Apps with AI","url":"https://addaly.com/learn/building-apps-with-ai","level":"beginner","track":"build"},"lesson":{"slug":"git-when-you-have-never-used-it","title":"Save points: git when you have never used it","url":"https://addaly.com/learn/building-apps-with-ai/git-when-you-have-never-used-it","position":37,"of":87,"minutes":9,"answer":"A commit made while the app works is the only thing that makes a bad hour cost an hour.","keyIdea":"A commit made while the app works is the only thing that makes a bad hour cost an hour."},"body":{"format":"markdown","text":"## What git actually is\n\nGit is save points for a folder of files. That is the whole idea. You tell it \"remember everything exactly as it is right now,\" and later you can come back to that exact moment, or see precisely what changed since.\n\nIf you have never used it, you have been building without save points, which is why a bad hour can cost you a day.\n\nGit is not a backup service. It is not GitHub. It runs on your machine and works with no internet and no account. GitHub is a place to send a copy, which is a separate step and a separate lesson's worth of value.\n\n## The five commands\n\nOpen a terminal in your project folder. If your tool did not already set git up, run `git init` once.\n\n```bash\ngit status\n# What has changed since the last save point. Run this constantly.\n\ngit diff\n# Exactly which lines changed. Green added, red removed.\n\ngit add -A && git commit -m \"Booking form saves to the database\"\n# Make a save point of everything, with a note about what it is.\n\ngit log --oneline\n# Your save points, newest first, each with a short id like a3f9c21.\n\ngit restore --staged --worktree .\n# Panic button. Throw away every change to tracked files since the last\n# save point, including anything you have git add-ed. (Files you never\n# added stay; git clean -n lists them and git clean -f removes them.)\n```\n\nThat is enough to work safely. To go further back:\n\n```bash\ngit reset --hard a3f9c21\n# Return the folder to exactly how it was at that save point.\n# Everything after it is gone. That is the point of it.\n```\n\nYour editor probably has buttons for all of this. Use them. Knowing the words still helps, because every answer you find online is written in them.\n\n## Commit when it works, not when you are finished\n\nThis is the habit that matters. The moment a feature does the thing (before you ask for the next change) commit.\n\nA save point is only valuable if the state it holds is good. Ten commits a day, each one a working app, means the worst possible outcome is losing twenty minutes. One commit a week means a bad afternoon costs you the week.\n\nWrite the message as what is now true, not what you did: \"Bookings can be cancelled by the customer\" rather than \"changes\". In three weeks you will be reading this list to find the last version that worked, and \"fixes\" and \"update\" and \"asdf\" will tell you nothing.\n\n## Branches, briefly\n\n```bash\ngit checkout -b payments\n```\n\nThat makes a parallel copy where you can try something risky. If it works, merge it. If it does not, `git checkout main` and the experiment never touched your working app.\n\nYou can build real things without ever using a branch. It is worth knowing for the day you want to try a large change without gambling the thing that currently works.\n\n## Two warnings\n\n**Never commit your secrets.** Passwords, API keys, database URLs. Make a file called `.gitignore` in your project with:\n\n```\n.env\n.env.local\nnode_modules\n```\n\nDo this before your first commit. Once a secret is committed and pushed, deleting the file does not remove it: it stays in the history, and bots scan public repositories for exactly this within minutes of a push. Lesson 8 covers what happens next.\n\n**Be careful with `git push --force`.** It can overwrite work, yours or a collaborator's. If a model suggests it while you are stuck, ask what it will overwrite before you agree.\n\n## The platform's history is not git\n\nReplit, Lovable and Bolt keep their own version history, and it is useful: a list of checkpoints you can roll back to inside the product.\n\nIt is not the same thing. It lives in their account, in their format, and it does not leave with you. When you export your project or move to another tool, that history usually does not come along. Connect the project to a git repository early if the platform allows it. You are not doubting the platform; you are making sure the record of your work is yours.\n\n## What good looks like\n\nEnd of a working session, you should be able to say: my app works, that state is committed, and if tomorrow goes badly I lose tomorrow and nothing else."},"check":{"question":"Someone commits every time their app reaches a working state. What does that habit actually give them?","options":[{"text":"A copy of their files stored safely off their laptop, so a hardware failure is survivable.","correct":false,"tempting":"Conflates committing with pushing to a remote: commits are local, and a stolen laptop takes them with it."},{"text":"A record of the conversation with the AI, so they can see why each change was made.","correct":false,"tempting":"Assumes history captures reasoning automatically, when it captures file contents and whatever the commit message happens to say."},{"text":"A set of known-good states they can return to, so a failed run of changes costs minutes rather than a day.","correct":true},{"text":"An undo function for the model's edits, letting them step back one change at a time as they go.","correct":false,"tempting":"Treats git as editor undo at edit granularity, when it works at the granularity of the save points you deliberately made."}]},"prev":{"slug":"asking-a-human","title":"Asking a human, and getting an answer","url":"https://addaly.com/learn/building-apps-with-ai/asking-a-human"},"next":{"slug":"what-a-commit-actually-is","title":"What a commit actually is","url":"https://addaly.com/learn/building-apps-with-ai/what-a-commit-actually-is"},"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Exam keys checked blind by a second model: 3,665 of 3,666 agreed. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'Save points: git when you have never used it', in Building Apps with AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/building-apps-with-ai/git-when-you-have-never-used-it (Accessed: 31 October 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"Save points: git when you have never used it","courseTitle":"Building Apps with AI","module":{"index":5,"slug":"save-points-and-shipping","title":"Save points, and shipping to a stranger"},"answer":null,"keyIdea":"A commit made while the app works is the only thing that makes a bad hour cost an hour.","hero":{"kind":"plate","image":null,"alt":null,"caption":null},"blocks":[{"t":"h2","id":"what-git-actually-is","runs":[{"text":"What git actually is"}]},{"t":"p","runs":[{"text":"Git is save points for a folder of files. That is the whole idea. You tell it “remember everything exactly as it is right now,” and later you can come back to that exact moment, or see precisely what changed since."}]},{"t":"p","runs":[{"text":"If you have never used it, you have been building without save points, which is why a bad hour can cost you a day."}]},{"t":"p","runs":[{"text":"Git is not a backup service. It is not GitHub. It runs on your machine and works with no internet and no account. GitHub is a place to send a copy, which is a separate step and a separate lesson’s worth of value."}]},{"t":"h2","id":"the-five-commands","runs":[{"text":"The five commands"}]},{"t":"p","runs":[{"text":"Open a terminal in your project folder. If your tool did not already set git up, run "},{"text":"git init","code":true},{"text":" once."}]},{"t":"code","lang":"bash","label":"Bash","text":"git status\n# What has changed since the last save point. Run this constantly.\n\ngit diff\n# Exactly which lines changed. Green added, red removed.\n\ngit add -A && git commit -m \"Booking form saves to the database\"\n# Make a save point of everything, with a note about what it is.\n\ngit log --oneline\n# Your save points, newest first, each with a short id like a3f9c21.\n\ngit restore --staged --worktree .\n# Panic button. Throw away every change to tracked files since the last\n# save point, including anything you have git add-ed. (Files you never\n# added stay; git clean -n lists them and git clean -f removes them.)"},{"t":"p","runs":[{"text":"That is enough to work safely. To go further back:"}]},{"t":"code","lang":"bash","label":"Bash","text":"git reset --hard a3f9c21\n# Return the folder to exactly how it was at that save point.\n# Everything after it is gone. That is the point of it."},{"t":"p","runs":[{"text":"Your editor probably has buttons for all of this. Use them. Knowing the words still helps, because every answer you find online is written in them."}]},{"t":"h2","id":"commit-when-it-works-not-when-you-are-finished","runs":[{"text":"Commit when it works, not when you are finished"}]},{"t":"p","runs":[{"text":"This is the habit that matters. The moment a feature does the thing (before you ask for the next change) commit."}]},{"t":"p","runs":[{"text":"A save point is only valuable if the state it holds is good. Ten commits a day, each one a working app, means the worst possible outcome is losing twenty minutes. One commit a week means a bad afternoon costs you the week."}]},{"t":"p","runs":[{"text":"Write the message as what is now true, not what you did: “Bookings can be cancelled by the customer” rather than “changes”. In three weeks you will be reading this list to find the last version that worked, and “fixes” and “update” and “asdf” will tell you nothing."}]},{"t":"h2","id":"branches-briefly","runs":[{"text":"Branches, briefly"}]},{"t":"code","lang":"bash","label":"Bash","text":"git checkout -b payments"},{"t":"p","runs":[{"text":"That makes a parallel copy where you can try something risky. If it works, merge it. If it does not, "},{"text":"git checkout main","code":true},{"text":" and the experiment never touched your working app."}]},{"t":"p","runs":[{"text":"You can build real things without ever using a branch. It is worth knowing for the day you want to try a large change without gambling the thing that currently works."}]},{"t":"h2","id":"two-warnings","runs":[{"text":"Two warnings"}]},{"t":"p","runs":[{"text":"Never commit your secrets.","b":true},{"text":" Passwords, API keys, database URLs. Make a file called "},{"text":".gitignore","code":true},{"text":" in your project with:"}]},{"t":"code","lang":"","label":"Text","text":".env\n.env.local\nnode_modules"},{"t":"p","runs":[{"text":"Do this before your first commit. Once a secret is committed and pushed, deleting the file does not remove it: it stays in the history, and bots scan public repositories for exactly this within minutes of a push. Lesson 8 covers what happens next."}]},{"t":"p","runs":[{"text":"Be careful with ","b":true},{"text":"git push --force","b":true,"code":true},{"text":".","b":true},{"text":" It can overwrite work, yours or a collaborator’s. If a model suggests it while you are stuck, ask what it will overwrite before you agree."}]},{"t":"h2","id":"the-platform-s-history-is-not-git","runs":[{"text":"The platform’s history is not git"}]},{"t":"p","runs":[{"text":"Replit, Lovable and Bolt keep their own version history, and it is useful: a list of checkpoints you can roll back to inside the product."}]},{"t":"p","runs":[{"text":"It is not the same thing. It lives in their account, in their format, and it does not leave with you. When you export your project or move to another tool, that history usually does not come along. Connect the project to a git repository early if the platform allows it. You are not doubting the platform; you are making sure the record of your work is yours."}]},{"t":"h2","id":"what-good-looks-like","runs":[{"text":"What good looks like"}]},{"t":"p","runs":[{"text":"End of a working session, you should be able to say: my app works, that state is committed, and if tomorrow goes badly I lose tomorrow and nothing else."}]}],"check":{"question":[{"text":"Someone commits every time their app reaches a working state. What does that habit actually give them?"}],"options":[{"text":[{"text":"A copy of their files stored safely off their laptop, so a hardware failure is survivable."}],"correct":false,"tempting":[{"text":"Conflates committing with pushing to a remote: commits are local, and a stolen laptop takes them with it."}]},{"text":[{"text":"A record of the conversation with the AI, so they can see why each change was made."}],"correct":false,"tempting":[{"text":"Assumes history captures reasoning automatically, when it captures file contents and whatever the commit message happens to say."}]},{"text":[{"text":"A set of known-good states they can return to, so a failed run of changes costs minutes rather than a day."}],"correct":true,"tempting":null},{"text":[{"text":"An undo function for the model’s edits, letting them step back one change at a time as they go."}],"correct":false,"tempting":[{"text":"Treats git as editor undo at edit granularity, when it works at the granularity of the save points you deliberately made."}]}],"order":[0,1,3,2],"why":null},"prev":{"slug":"asking-a-human","title":"Asking a human, and getting an answer","minutes":8},"next":{"slug":"what-a-commit-actually-is","title":"What a commit actually is","minutes":8}}}