Managing multiple project versions in the same GitHub repository

Apr 17, 2026

I have been working on a project for years, and suddenly I have to create a completely different version of the same codebase.

In my case, I have:

Now, my goal is

I followed a clean and safe approach, which I am explaining step-by-step below. If you have ever come to such a situation, you may follow this process.

Step 1: Create a New Branch for Version 1

First, go to your existing project (Folder 1) and create a new branch from current main. It will safely move your code into version1 branch

cd /path/to/folder1
git checkout -b version1
git push origin version1

Step 2: Setup Git in Version 2 Folder

cd /path/to/folder2
git init
git remote add origin <your-repository-url>

Step 3: Push Version 2 Code to Main Branch

Create and switch to main branch:

git checkout -b main
git add .
git commit -m "Initial commit for version 2"
git push origin main --force

As the main brance already had version 1 code, so –force push is used to overwrite the main brance.