First Commit
Put the project under Git with a single commit holding the site, keep debug.log out of history for good, and leave a clean working tree.
- git-init
- staging
- commits
- gitignore
Real-world Git problems. No step-by-step instructions: just a scenario, a mission and a repository that needs you.
Repositories, staging and commits.
Put the project under Git with a single commit holding the site, keep debug.log out of history for good, and leave a clean working tree.
Branches, HEAD and moving between them.
Move both login commits onto a new branch called feature/login, and put main back where it was before you started.
Make sure both commits survive on a branch called fix/rounding, then get back to main.
Merge hotfix/rounding into release, then get back to main with your unfinished price work exactly as it was, not committed, and nothing left stashed.
When two changes collide.
Bring release/2.0 into main with a merge commit. Keep the new host and the longer timeout, decide what happens to the setup guide, and finish on main with nothing left uncommitted.
Put feature/retries on top of the current main while keeping the new region and the higher retry count in src/settings.js. Finish on the feature branch with no conflict or local change.
Undoing mistakes and finding lost work.
Rewrite the last commit so that config.js is committed but secrets.env never was, ignore secrets.env from now on, and keep history to two commits.
Bring feature/payments back with both of its commits, without touching main.
Visit main, then return to feature/invoice-notes with the invoice edit still modified and uncommitted, your launch draft restored as an untracked file, and no work left in the stash.
Turn the unfinished checkout back off while preserving the faulty commit, the earlier export work, and the shared history. Leave main clean.
Restore the deployment checklist with its original contents, preserve the newer health endpoint work, and leave the restoration recorded on a clean main branch.
Copying and reshaping commits.
Get the crash fix into release/1.4 without bringing any of main's new features along.
Replace the four messy commits with a single commit called Add search, keeping the final code exactly as it is.
Put both notification commits directly on top of the current main, keep main exactly where it is, and finish on feature/notifications with a clean working tree.
Replace the mixed commit with Add analytics service, changing only the service file, followed by Document analytics service, changing only the guide. Preserve both files and finish clean.
Several problems at once.
Restore main with Add invoice PDFs, bring back feature/reports with its commit, commit the stashed dark-mode work on main as Add dark mode, and leave the stash empty and the working tree clean.
Restore each branch to its own completed commit without moving the other branch, then finish on feature/catalog with a clean working tree and both pieces of work reachable.