How to Manage Iterations and Improvements in a Project Using Git

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:

git branch

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:

git checkout 2-Works-But-Needs-UX-Color-Fix

Step 2 — Create a New Branch for Version 3

Create a new branch and switch to it immediately:

git checkout -b 3-Fixes-Cards-Update-From-2
  • -b tells 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.

Also READ  What Can I Do With My Old Phone

Step 4 — Stage Your Changes

Add your changes to the staging area so Git knows you want to commit them:

git add .

This stages all changed files.
You can also stage specific files:

git add lib/main.dart

Step 5 — Commit Your Changes

Create a snapshot of your changes with a descriptive message:

git commit -m "Update cards UI and improve UX based on version 2"
  • 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:

git push origin 3-Fixes-Cards-Update-From-2
  • GitHub now has a separate branch for version 3.

  • Your main and branch 2 remain untouched.


Step 7 — Verify on GitHub

  1. Open your repository on GitHub.

  2. Click the branch selector dropdown.

  3. You should see 3-Fixes-Cards-Update-From-2 listed.

  4. Clicking it shows your new changes.


Visual Tree Example

main (version 1) ──> 2-Works-But-Needs-UX-Color-Fix (version 2) ──> 3-Fixes-Cards-Update-From-2 (version 3)
  • 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

  1. Never commit directly to main unless it’s truly a stable version.

  2. Always branch from the version you want to improve.

  3. Commit frequently with meaningful messages.

  4. Push branches to GitHub regularly — it’s your backup.

  5. 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.

Also READ  A Simple Git Workflow for Solo Developers

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.

Scroll to Top