Overslaan naar inhoud
CTech Digital
  • Startpagina
  • Odoo services
  • AI services
  • Contact
  • 0
  • Nederlands (BE) English (UK) Français
CTech Digital
  • 0
    • Startpagina
    • Odoo services
    • AI services
    • Contact
  • Nederlands (BE) English (UK) Français

GIT orphan

  • Alle blogs
  • Daily blog
  • GIT orphan
  • 22 november 2025 in
    CTech Metrology, Luc Wens

    The "Split-Brain" Git Workflow Guide

    This document outlines a strategy to maintain a massive, history-heavy Git repository (derived from SVN) on a local/Dropbox remote while simultaneously maintaining a lightweight, clean version on GitHub for modern development and AI agents (like Jules).

    The concept was tried out on a repository called GitOrphan:

    • Dropbox : D:\Dropbox\GIT\GitOrphan
    • GitHub : https://github.com/lucwens/GitOrphan

    1. The Concept

    You will essentially run two parallel universes within a single local repository:

    • main (Heavy): Connected to Dropbox. Contains years of history and large binaries.
    • github-release (Light): Connected to GitHub. Contains only the latest snapshot and small source files.

    2. Initial Setup (One-Time)

    Perform this sequence to create the lightweight "orphan" branch without deleting your actual files.

    Step A: Create the Orphan

    # 1. Create a branch with zero history
    git checkout --orphan github-release
    

    Step B: The "Cleanse"

    The orphan branch initially stages everything. We must unstage files to apply new ignore rules.

    # 2. Unstage all files (does not delete them from disk)
    git reset .
    
    # 3. Create a specific .gitignore for this branch
    # Add patterns to exclude your large binaries/assets
    echo "*.psd" >> .gitignore
    echo "large_assets_folder/" >> .gitignore
    echo "*.zip" >> .gitignore
    

    Step C: Commit and Push

    # 4. Add files (Git will now respect the new .gitignore)
    git add .
    
    # 5. Initial commit
    git commit -m "Initial clean release for GitHub"
    
    # 6. Add GitHub remote and push
    git remote add github https://github.com/YOUR_USER/YOUR_REPO.git
    git push -u github github-release
    

    3. Architecture Overview

    This diagram shows how your local machine acts as the bridge between the two disconnected remotes.

    4. Routine: Updating GitHub (Pushing Up)

    When you have done work on main and want to update the GitHub version, use a Squash Merge. This prevents the massive history from flowing into GitHub.

    The "Squash & Reset" Cycle

    Commands

    # 1. Go to the light branch
    git checkout github-release
    
    # 2. Merge changes without history
    git merge --squash main --allow-unrelated-histories
    
    # 3. Reset to enforce .gitignore rules
    # (Crucial: ensures large files added in 'main' don't sneak in)
    git reset .
    git add .
    
    # 4. Commit and Push
    git commit -m "Sync with main: Feature Updates"
    git push github github-release
    

    5. The Jules / AI Workflow (Harvesting Down)

    When using an AI agent like Jules on GitHub, the flow changes. Jules works on the remote, and you "harvest" the code back to your heavy local repo.

    Workflow Diagram

    Local Heavy (Main)Local Light BranchGitHub (Light)AI Agent (Jules)Local Heavy (Main)Local Light BranchGitHub (Light)AI Agent (Jules)1. AI Development Loop2. The HarvestSpawns Feature BranchOpens Pull RequestUser Merges PR (on Web)git pullgit merge --no-commitCommit & Push to Dropbox

    The Harvest Commands

    Use this sequence when Jules has finished a task and you've merged its PR on the GitHub website.

    # 1. Update your local light branch
    git checkout github-release
    git pull github github-release
    
    # 2. Switch to your heavy main branch
    git checkout main
    
    # 3. Merge the AI work (Carefully!)
    # --no-commit: Lets you inspect files before finalizing
    # --allow-unrelated-histories: Required because branches are disconnected
    git merge --no-commit github-release --allow-unrelated-histories
    
    # 4. Verify and Finalize
    # Check git status to ensure no 'ignored' files were deleted/added unexpectedly
    git commit -m "Merged feature X from Jules"
    
    # 5. Backup to Dropbox
    git push origin main
    

    6. Critical Safety Rules

    1. Never git merge main into github-release without --squash.

      • Risk: You will accidentally push 10 years of history to GitHub.
    2. Never git push origin github-release.

      • Risk: You will clutter your Dropbox backup with the light branch. Keep them strictly separated.
    3. Watch your .gitignore on the Light Branch.

      • If you change .gitignore on main, remember to manually update it on github-release too, or the "Squash & Reset" trick might fail to exclude new large files.


    Renaming Master to Main (Dropbox & GitHub)

    This guide documents the procedure to rename the default branch from master to main in a repository with two specific remotes:

    1. Dropbox (A local "bare" repository on your hard drive)

    2. github (A standard cloud repository)

    Phase 1: Local Rename

    First, rename the branch on your working machine.

    # 1. Switch to master (if not already there)
    git checkout master
    
    # 2. Rename it to main
    git branch -m master main
    

    Phase 2: Update Dropbox Remote

    Since the Dropbox remote is just a folder on your drive, you cannot "click a settings button" to change the default branch. You must do it manually via command line.

    1. Push the new branch

    git push Dropbox main
    

    2. Update the Default Branch (Crucial Step)

    You must tell the Dropbox folder that main is now the default.

    • Open PowerShell and navigate to your Dropbox folder (e.g., cd D:\Dropbox\GIT\GitOrphan).

    • Run this command inside that folder:

      git symbolic-ref HEAD refs/heads/main
      
    • Navigate back to your project folder.

    3. Delete the old branch

    Now that Dropbox knows main is the default, you can safely delete master.

    git push Dropbox --delete master
    

    Phase 3: Update GitHub Remote

    For GitHub, the default branch must be changed via their website interface.

    1. Push the new branch

    git push github main
    

    2. Update Settings on GitHub.com

    • Go to your repository on GitHub.com.

    • Navigate to Settings -> General -> Default Branch.

    • Click the pencil/edit icon and switch master to main.

    • Confirm the change.

    3. Delete the old branch

    git push github --delete master
    

    Phase 4: Final Cleanup

    Remove the old reference from your local machine to keep things clean.

    git branch -d master
    

    Phase 5: Verify

    Run this command to ensure only main exists everywhere.

    git branch -a
    

    Expected Output:

    * main
      remotes/Dropbox/main
      remotes/github/main
    

    Applying this to CTrack

    Syncing everything into main

    At the moment we were still working in a branch called ObserverPattern.

    First we need to bring this into main, even though we are not finished yet, we're going to do that in order to make it possible to assign work to Jules in the way as above, otherwise we get too much confusing branches.

    Our main/master branch on dropbox is called master. On Github there is nothing at all yet.


    in Daily blog
    # GIT
    Comau
    Upgrading their installation
    Copyright © CTech
    Nederlands (BE) | English (UK) | Français
    Aangeboden door Odoo - De #1 Open source e-commerce