Skip to content

rakib06/mini-github

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌐 Git Hub - Shared Drive Repository Manager

A lightweight, self-hosted Git repository manager for browsing repos stored on a shared network drive. Features local caching and automatic sync for fast performance.

🎯 Features

βœ… Browse Repositories - List all Git repos from shared drive
βœ… Create Bare Repos - Initialize --bare repos via PowerShell for LAN shared drives
βœ… View Branches - See all branches in each repository
βœ… View Commits - Browse commit history with hash, message, and author
βœ… Clone Commands - Copy-to-clipboard git clone commands (UNC + local)
βœ… Auto Sync - Automatically clones repos and pulls every minute
βœ… Local Cache - Stores repos locally for fast access
βœ… Network Resilient - Handles shared drive unavailability gracefully
βœ… Multi-User - Run on each PC to access shared repos
βœ… Permission Error Help - Shows exact PowerShell commands if bare init fails

πŸ”’ Bare Repositories (Recommended for Shared Drives)

When creating repositories on a LAN shared drive, bare repositories are strongly recommended. Unlike normal repos, bare repos:

  • Have no working directory β€” no checked-out files to conflict with
  • Allow multiple users to push without "refusing to update checked out branch" errors
  • Act as a central remote that everyone clones from and pushes to

Creating a Bare Repository

In the web UI, check "Bare repo (recommended for shared drives)" when creating a new repository. The app will use PowerShell to run:

git init --bare "\\192.168.1.100\sharedrive\repos\my-project"

If PowerShell Permission Fails

If the app cannot create the bare repo due to permissions, it will show an error page with the exact commands to run manually. Open PowerShell as Administrator and execute the displayed command, then refresh the page.

Why Not Normal Repos?

A normal (non-bare) repo on a shared drive has a working directory. Git refuses pushes to the currently checked-out branch by default, causing errors when team members try to push their work. A bare repo avoids this entirely.


πŸ—οΈ How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Shared Drive (\\192.168.1.0\repos)        β”‚
β”‚  - Stores master copies of all repos       β”‚
β”‚  - Accessed simultaneously by all users    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            ↑ (initial clone)
            β”‚ (pull every 1 min)
            ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  User PC #1 (temp_local/)                  β”‚
β”‚  App discovers & clones repos locally      β”‚
β”‚  Auto-syncs every 60 seconds               β”‚
β”‚  Shows in GitHub-like UI                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Same for User PC #2, PC #3, etc.

Process Flow

  1. User opens app β†’ App discovers repos on shared drive
  2. First access to repo β†’ Repo is cloned to local temp_local_{reponame} folder
  3. Background sync β†’ Every 1 minute, all repos are auto-pulled to stay in sync
  4. UI displays β†’ Shows commits, branches from local cache (fast!)
  5. Next user opens β†’ Their app does the same independently

πŸ“¦ Setup

1. Install Dependencies

python -m venv venv
venv\Scripts\activate
pip install fastapi uvicorn gitpython jinja2

2. Configure Paths (config.py)

Edit config.py and set your paths:

# Shared drive (master repos)
REPO_BASE = r"\\192.168.1.0\sharedrive\repos"

# Local cache folder
TEMP_LOCAL_BASE = r"C:\Users\rakib\Desktop\GitSimu\temp_local"

# Auto-sync interval (seconds)
SYNC_INTERVAL = 60  # Pull every 1 minute

3. Run the Server

uvicorn app:app --reload

Access at: http://127.0.0.1:8000

πŸ“ Directory Structure

webserver/
β”œβ”€β”€ app.py              # Main FastAPI application
β”œβ”€β”€ config.py           # Configuration (shared drive & local paths)
β”œβ”€β”€ requirements.txt    # Python dependencies
β”œβ”€β”€ templates/
β”‚   β”œβ”€β”€ index.html      # Repo dashboard with sync status
β”‚   β”œβ”€β”€ repo.html       # Repository view with branches
β”‚   β”œβ”€β”€ commits.html    # Commit history
β”‚   └── error.html      # Error page
└── venv/              # Virtual environment

[Auto-Generated]
temp_local/             # Local cache (per machine)
β”œβ”€β”€ repo1/              # Auto-cloned from shared drive
β”œβ”€β”€ repo2/
└── repo3/

πŸ”§ Configuration Examples

Local Testing

REPO_BASE = r"C:\repos\shared"
TEMP_LOCAL_BASE = r"C:\repos\temp_local"

Windows Network Share

REPO_BASE = r"\\192.168.1.100\sharedrive\repos"
TEMP_LOCAL_BASE = r"C:\cached_repos"

UNC Path with Authentication

REPO_BASE = r"\\fileserver\shared\git\repos"
TEMP_LOCAL_BASE = r"C:\users\username\AppData\Local\git_cache"

πŸš€ Workflow

For Users

  1. Open app on your PC: http://localhost:8000
  2. Browse repos, view commits, branches
  3. Copy clone command (points to shared drive)
  4. Clone to your local machine with: git clone "\\192.168.1.100\repos\my-repo"

For Teams

  • Shared Drive = Central storage (all repos)
  • Each PC's temp_local = Personal cache (auto-synced every minute)
  • UI = Browse from cache (fast, reliable)
  • Clone = Still from shared drive (latest source of truth)

πŸ“Š Sync Status

The UI shows sync status for each repository:

  • βœ… Synced - Repo is up-to-date with shared drive
  • ⏳ Syncing... - Currently pulling from shared drive
  • ⚠️ Error - Problem accessing or syncing repo

πŸ”— Clone Command Format

Change this in repo.html based on your network setup:

# For UNC path
git clone "\\192.168.1.100\repos\repo-name"

# For mapped drive letter
git clone "Z:\repos\repo-name"

# For local path (testing)
git clone "C:\SharedDrive\repos\repo-name"

πŸ› οΈ API Endpoints

Web UI

  • GET / - Repository listing
  • GET /repo/{name} - Repository details
  • GET /repo/{name}/commits - Commit history
  • POST /create - Create new repository

Status API (for debugging)

  • GET /api/status - Returns {"last_sync": "...", "syncing": false, "repos": {...}}

πŸ“₯ Requirements

  • Python 3.7+
  • Git installed (for managing repos)
  • Network access to shared drive
  • Default: Uses local testing path (works out of box!)

πŸ”§ Troubleshooting

"Shared Drive Unavailable" Error

  • Check network connection
  • Verify shared drive is online and accessible
  • Run: ping 192.168.1.100 (replace with your share)
  • Check file permissions on shared drive

Repos Not Syncing

  • Check if TEMP_LOCAL_BASE directory is writable
  • Verify Git is installed: git --version
  • Check server logs for error details
  • Manually trigger sync by refreshing the page

Clone Fails

  • Ensure you use correct network path in clone command
  • If on different PC, map the shared drive first:
    net use Z: \\192.168.1.100\sharedrive
    git clone Z:\repos\my-repo

πŸ“ Next Steps (Future)

  • File browser - view/edit repo contents in web UI
  • Web editor - edit files directly
  • Push operations - commit and push via UI
  • User authentication - per-user access control
  • Repo settings - description, README display
  • Pull/Merge requests - code review interface

πŸ“¦ Install All Dependencies

pip install -r requirements.txt

πŸ’‘ Tips

  • First time? Start with local testing paths - it all works locally!
  • Production? Update config.py with your actual shared drive path
  • Performance? Local caching makes it fast even with network latency
  • Automation? Set up Windows Task Scheduler to run app on startup

Made with ❀️ for teams sharing Git repos

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors