This post may contains affiliate links. As an amazon associate I earn from qualifying purchases.
How to Improve a Previous Version Without Messing Up Your Main Code
When working on a project, especially a Flutter app, it’s common to create multiple iterations of your code — tweaking features, improving UI/UX, or fixing bugs. Git and GitHub make it easy to manage multiple versions without losing any working code.
In this guide, we’ll walk through a typical scenario:
You have a working version on
main(version 1).You created a second branch for improvements (version 2).
Now you want to make a third version as an improvement on version 2 without touching
main.
Step 1 — Check Your Current Branch
Open your terminal in the project folder:
This shows the branches in your repo and highlights the one you’re currently on.
Make sure you are on the branch you want to base your next improvements on (in this case, 2-Works-But-Needs-UX-Color-Fix).
If not, switch to it:
Step 2 — Create a New Branch for Version 3
Create a new branch and switch to it immediately:
-btells Git to create a new branch.Give the branch a descriptive name so it’s clear it’s based on version 2.
Tip: A good branch name helps you understand what’s inside without opening it.
Step 3 — Make Your Changes
Open your project in VS Code (or any editor).
Edit your files as needed.
For example, tweak card layouts, adjust colors, or update UX.
Save your changes locally.
At this point, all edits exist only on your local machine in branch 3.
Step 4 — Stage Your Changes
Add your changes to the staging area so Git knows you want to commit them:
This stages all changed files.
You can also stage specific files:
Step 5 — Commit Your Changes
Create a snapshot of your changes with a descriptive message:
A commit is like a save point for your branch.
The commit message should summarize what changes were made.
Step 6 — Push the New Branch to GitHub
Upload your new branch so it’s safe and accessible online:
GitHub now has a separate branch for version 3.
Your
mainand branch 2 remain untouched.
Step 7 — Verify on GitHub
Open your repository on GitHub.
Click the branch selector dropdown.
You should see
3-Fixes-Cards-Update-From-2listed.Clicking it shows your new changes.
Visual Tree Example
Each branch is a snapshot of your project at a point in time.
You can freely switch between them to review, test, or continue work.
Key Tips
Never commit directly to main unless it’s truly a stable version.
Always branch from the version you want to improve.
Commit frequently with meaningful messages.
Push branches to GitHub regularly — it’s your backup.
Use descriptive branch names — it saves you from confusion later.
Typical Scenario
Imagine you have:
main: First fully working version.2-Works-But-Needs-UX-Color-Fix: Added card improvements but UI needs tweaks.3-Fixes-Cards-Update-From-2: Further UX and color fixes on version 2.
You can switch between them anytime, make changes, and push updates without ever disturbing the original main.
This workflow ensures safe, structured development and avoids losing your working code while experimenting with improvements.
This post may contains affiliate links. As an amazon associate I earn from qualifying purchases.