The GitPHP guide 🚀
Comprehensive open-source documentation: Self-hosting, Personal Access Tokens, Git & SSH, pull requests, and REST API.
🚀 Remote Updaters & CI/CD Token Architecture (upd_*)
NEW
Authorizes automated CLI installers (such as antigravity-installer-linux), headless servers, and CI/CD pipelines to download repository releases and source code archives directly without interactive browser prompts.
Personal Account upd_* Token
Every member gets an isolated permanent token starting with upd_... that can be copied or regenerated at any time.
Full cURL & Wget Compatibility
Pass the token via the X-Update-Token header or the query parameter ?token=upd_*.
Short-Link Anti-Scraping Shield
Unauthorized raw download requests automatically redirect to the verified short-link download gateway.
Automation & Shell Examples:
# 1. Download release assets via X-Update-Token header (Recommended):
curl -sSL -H "X-Update-Token: upd_YOUR_PERSONAL_TOKEN" \
"https://git.ysnapp.com/username/repository/releases/download/v1.0.0/app.tar.gz" -o app.tar.gz
# 2. Download repository source archives directly:
curl -sSL -H "X-Update-Token: upd_YOUR_PERSONAL_TOKEN" \
"https://git.ysnapp.com/username/repository/archive/main.zip" -o source.zip
# 3. Using direct query token with Wget:
wget "https://git.ysnapp.com/d/SHORT_CODE/get?token=upd_YOUR_PERSONAL_TOKEN" -O package.zip
/settings/updates.
☁️ Unified Download Portal & Broken Link Reporting (/d/* Gateway)
NEWAn ultra-fast, security-audited portal for all shared platform assets, binaries, and repository archives with real-time integrity verification.
Automated SHA-256 Checksum
Automatic cryptographic hash computation with one-click copy to verify file integrity prior to installation.
Broken Link Reporting System
Visitors can immediately report corrupt, missing, or slow downloads with automatic logging to the admin dashboard.
Responsive Large-Screen Sidebar
Desktop-optimized sidebar presenting live cluster activity, verification badges, and file specifications.
📦 Installation & Self-Hosting Guide
Open SourceGitPHP is completely open-source and engineered to be lightweight, high-performance, and trivial to install on any shared Linux hosting or dedicated VPS without requiring Docker or bloated runtime services.
📋 System Requirements:
- Operating System: Modern Linux (Ubuntu 20.04+, Debian 11+, AlmaLinux 9+, Rocky Linux, RHEL).
- PHP Version: PHP 8.1 or newer (PHP 8.2 / 8.3 recommended) with extensions:
pdo_mysql,mbstring,curl,intl,sodium,fileinfo. - Database: MariaDB 10.6+ or MySQL 8.0+.
- Git Engine: Git 2.30+ installed server-wide and available in
$PATH. - Package Manager: Composer 2.x.
- Web Server: OpenLiteSpeed / LiteSpeed, Nginx, or Apache.
🚀 Quick Command-Line (CLI) Installation:
1. Clone Repository & Install Dependencies:
# Clone repository into web directory
git clone https://github.com/ysnapp/gitphp.git /var/www/gitphp
cd /var/www/gitphp
# Install production dependencies
composer install --no-dev --optimize-autoloader
2. Configure Environment & Database:
# Copy configuration template
cp config/config.example.php config/config.php
# Edit database credentials and application settings
nano config/config.php
3. Run the Automated Installer:
# Execute the interactive CLI installer
php bin/install.php
# Or run the browser installer wizard by navigating to:
# https://your-domain.com/install.php
4. Set Permissions & Run Diagnostic:
# Grant ownership to your web user (www-data / nobody / site user)
chown -R www-data:www-data /var/www/gitphp/
chmod -R 755 /var/www/gitphp/
chmod -R 775 /var/www/gitphp/data/ /var/www/gitphp/storage/
# Run the health & push verification script
php bin/fix-push.php
public_html/install.php or the application will automatically block access for security.⚙️ Web Server Configuration (OpenLiteSpeed / Nginx / Apache)
Point your Document Root to the public_html directory and ensure URL rewrites and Authorization headers are passed:
a) OpenLiteSpeed / CyberPanel:
In CyberPanel → Websites → Manage → vHost Conf, set the document root and rewrite rules:
# In vHost Configuration:
docRoot /home/git.ysnapp.com/public_html
vhssl {
enableContextRewrite 1
}
# .htaccess rules in public_html/.htaccess:
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
b) Nginx Server Block:
server {
listen 80;
server_name git.example.com;
root /var/www/gitphp/public_html;
index index.php;
client_max_body_size 500M;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTP_AUTHORIZATION $http_authorization;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
c) Background Cron Job:
Add the recurring task in crontab to execute repository synchronizations, dispatch webhooks, and purge expired sessions:
# Edit crontab for web user
crontab -u www-data -e
# Add one-minute background trigger:
* * * * * php /var/www/gitphp/bin/cron.php >/dev/null 2>&1
docs/installation.md and docs/deploy.md.1 Overview
GitPHP is a self-hosted Git repository management platform with a modern GitHub-like interface. It provides high-performance Git hosting over HTTP (Personal Access Tokens & Basic auth) and guarded SSH, coupled with an integrated collaboration layer: Pull Requests, inline code review, branch protection, webhooks, and a REST API.
Multi-Protocol Git Hosting
Clone / Fetch / Push over HTTP with Personal Tokens or password, plus guarded SSH.
Pull Requests & Merging
Sequential numbering, discussion, changed files view, and one-click merges.
Inline Code Review
Comment on any diff line; approve or request changes.
Webhooks
HMAC-SHA256 signed event payloads for push, issues, PRs, and releases.
Branch Protection
Block deletion, prevent force-pushes, and require approved reviews before merge.
REST API & Tokens
Full read/write capabilities authenticated by personal gtp_… tokens.
2 Quick Start — Create Your First Repository
Create a new repository from New repository in the top navigation or your account menu, then set the name, description, and visibility (Public / Private).
https://git.ysnapp.com/aburasha/my-project.git⭐️ Personal Access Token Push (PAT)
Recommended for Security & CI/CD
Personal Access Tokens (PAT) let you authenticate and push to your repositories securely without exposing or entering your primary account password.
Tokens are generated as gtp_… strings and stored safely hashed (SHA-256) in the database.
1. Generate Token
Under Settings → Access Tokens (or direct URL /settings/tokens), choose a name, select write scope, and copy your token.
2. Use with Git
Paste the token in place of your password whenever running git push or git clone.
3. Instant Revocation
If a token is leaked or no longer needed, revoke it in one click without altering your account credentials.
Practical Usage Examples:
1. Cache locally via Git Credential Store:
# Enable local credential caching
git config --global credential.helper store
# Push and input credentials once
git push https://git.ysnapp.com/aburasha/my-project.git main
# Username: aburasha
# Password: gtp_your_token_here
2. Direct Remote URL with Token:
git remote set-url origin https://aburasha:[email protected]/aburasha/my-project.git
git push origin main
3. Continuous Integration (CI/CD) — GitHub Actions & GitLab CI:
# In GitHub Actions:
- name: Push to GitPHP
env:
GIT_TOKEN: ${{ secrets.GITPHP_TOKEN }}
run: |
git remote set-url origin https://aburasha:${GIT_TOKEN}@git.ysnapp.com/aburasha/my-project.git
git push origin main
write scope allows pushing, cloning, and full API access, while the read scope is restricted to cloning and reading API data only.gitsig_*) are deprecated and no longer recommended for new workflows. Please migrate to official supported methods:
- Interactive Push / CLI: Use standard Personal Access Tokens (PAT) (
pat_*) or SSH Keys. - CI/CD & Headless Updaters: Use the modern Remote Updates Architecture (
upd_*) via/settings/updates.
Signed Push Signatures [Deprecated]
Deprecated Feature
This legacy capability generated temporary capability tokens formatted as gitsig_…. Please refrain from configuring new automation with this method and switch to the supported upd_* or PAT mechanisms.
Single-Use Burn Mode
Legacy single-use token burn upon completion.
Expiration Scope
Short-lived duration enforcement.
Repository & IP Scoping
Strict network binding.
4 Pushing and Cloning over HTTP (Standard Password)
a) Push an existing local project
cd my-project
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://git.ysnapp.com/aburasha/my-project.git
git push -u origin main
b) Clone and Pull
git clone https://git.ysnapp.com/aburasha/my-project.git
cd my-project
git pull origin main
5 Pushing and Cloning over SSH
SSH keys allow passwordless, encrypted Git operations via port 22:
- Generate a new SSH key (Ed25519 recommended):
ssh-keygen -t ed25519 -C "[email protected]" - Copy your public key:
cat ~/.ssh/id_ed25519.pub - Add the key under Settings → SSH keys in your account.
- Test the server connection:
ssh -T [email protected] - Use the SSH clone URL:
git clone [email protected]:aburasha/my-project.git git push origin main
docs/ssh-setup.md.6 Branches, Compare & Merge
Create a Branch
From the Branches page → New branch; pick the base branch and your new branch name.
Compare
Inspect commits ahead/behind, unified diffs, and automatic merge conflict detection.
Direct Merge
Merge branches directly while preserving the full commit history.
7 Pull Requests
From the Pull requests tab → New pull request, select your source and target branches:
- Review the commit list, diff summary, and automatic mergeability.
- Enter a title and description, then open the PR (numbered sequentially #1, #2…).
- Collaborate via conversation comments and inspect the Files changed tab.
- When ready, click Merge pull request to execute the merge.
git merge-tree) with automatic conflict detection.8 Code Review
Open the Files changed tab inside any PR, then click any line in the diff to leave an inline review comment pinned to that exact code line.
9 Branch Protection
From repository settings → Branch protection, configure strict rules for main branches (e.g. main):
- Block deletion of protected branches.
- Block force-pushes (non-fast-forward updates).
- Require an approved review before merging.
- Optional admin bypass (allow admins to push directly).
pre-receive hooks for both Web and Git CLI operations.10 Webhooks
Under repository settings → Webhooks, register HTTP endpoints to receive real-time JSON payloads for events:
push— Pushes and branch creations/deletions.issues— Issue creation, comments, and state changes.pull_request— PR opening, review approvals, and merges.release— Release publications.
When configured with a Secret Key, payloads are HMAC-SHA256 signed in the X-GitPHP-Signature header.
11 REST API v1 Documentation ⚡️
A comprehensive RESTful API is provided for automation and integrations. Authenticate using personal access tokens (gtp_…) via Authorization: Bearer or X-GitPHP-Token headers.
1. Request Headers
# Standard Bearer Authentication:
Authorization: Bearer gtp_your_token_here
# Or custom header:
X-GitPHP-Token: gtp_your_token_here
2. Authenticated User Identity (Whoami)
curl -H "Authorization: Bearer gtp_your_token" \
https://git.ysnapp.com/api/v1/user
3. Repository Metadata
curl -H "Authorization: Bearer gtp_your_token" \
https://git.ysnapp.com/api/v1/repos/my-project
4. Commits History (Paginated)
curl -H "Authorization: Bearer gtp_your_token" \
"https://git.ysnapp.com/api/v1/repos/my-project/commits?ref=main&page=1&per_page=10"
5. Tree Browsing & Blob Content (Base64)
# Directory Tree
curl -H "Authorization: Bearer gtp_your_token" \
"https://git.ysnapp.com/api/v1/repos/my-project/tree?ref=main&path=src"
# File Blob Content
curl -H "Authorization: Bearer gtp_your_token" \
"https://git.ysnapp.com/api/v1/repos/my-project/blob?ref=main&path=README.md"
| Endpoint | Description | Query Parameters |
|---|---|---|
GET /api/v1/user | Token owner identity & scopes | — |
GET /api/v1/repos/{slug} | Repository metadata | — |
GET /api/v1/repos/{slug}/branches | Branch list with commit SHAs | — |
GET /api/v1/repos/{slug}/tags | Tags and releases list | — |
GET /api/v1/repos/{slug}/commits | Paginated commit log | ref, page, per_page |
GET /api/v1/repos/{slug}/tree | Directory tree browsing | ref, path |
GET /api/v1/repos/{slug}/blob | File contents (Base64) | ref, path |
GET /api/v1/repos/{slug}/issues | Issues list and state | state=open|closed|all |
GET /api/v1/repos/{slug}/pulls | Pull requests and review status | state=open|closed|all |
docs/api.md.12 Issues & Wiki
Issues: Track bugs and features with Markdown support, status labels, assignees, and threaded discussion comments.
Wiki: Built-in per-repository documentation in Markdown with automatic navigation.
13 Releases & Downloads
- Publish tagged Releases with release notes, assets, and Pre-release or Draft flags.
- Automatic source code archives in both
.zipand.tar.gz. - Download Center (
/d/{code}) for password-protected short download links with expiration limits.
14 File Management & Web Editor
- Full tree view with latest commit summary and timestamp per path.
- Syntax-highlighted blob viewer for 50+ languages with Blame and XSS-safe Raw modes.
- Interactive Web Editor: Create, edit, and delete files directly in the browser with commit message prompts.
- One-click zip/tarball downloads for any ref.
15 Accounts & Profiles
Users have dedicated profile pages at /u/{username} displaying public repositories and stars. Manage active sessions, 2FA, personal tokens, and SSH keys under Settings.
16 Platform Administration
The Admin Dashboard for platform owners provides:
- Platform metrics and 14-day activity traffic charts.
- Collaborator role assignment (
read/write) per repository. - Remote repository mirroring and sync from GitHub, GitLab, and Codeberg.
- Security audit logging and SSH key oversight.
- Maintenance helper script:
php bin/fix-push.php.
🛡️ Security Architecture & Permissions Model
Defense in DepthGitPHP enforces strict multi-layered security controls to isolate repositories, protect user credentials, and eliminate threats across web and Git transport layers.
1. Role-Based Access Control (RBAC) Matrix:
| Role / Level | Browse Code | Clone Repo | Push Commits | Manage Issues & PRs | Merge Pull Requests | Settings & Webhooks |
|---|---|---|---|---|---|---|
| Public Visitor | ✅ (Public only) | ✅ (Public only) | ❌ | ❌ | ❌ | ❌ |
Collaborator (read) |
✅ | ✅ | ❌ | ✅ (Comment) | ❌ | ❌ |
Collaborator (write) |
✅ | ✅ | ✅ (Unprotected) | ✅ (Full) | ✅ (If approved) | ❌ |
Repository Owner (admin) |
✅ | ✅ | ✅ (Full) | ✅ (Full) | ✅ (Full) | ✅ (Full + Delete) |
2. Core Security Pillars:
🔑 Argon2id Password Hashing
Industry standard password hashing resistant to GPU/ASIC-based brute-force attacks.
📲 Two-Factor Authentication (2FA)
Full RFC 6238 TOTP support (Google / MS Authenticator) with hashed emergency recovery keys.
⚡️ SHA-256 Token Hashing
Personal tokens (gtp_…) are strictly hashed in database with instant one-click revocation.
🔒 SSH User Hardening
Restricted git-shell-wrapper.php prevents interactive shell logins and confines users to Git commands only.
🛡️ Server-Side Branch Protection
Pre-receive hooks enforce deletion blocking, force-push prevention, and mandatory approved code reviews.
📜 Security Audit Logging
Comprehensive event logging for authentication, token generation, role assignments, and deletions.
docs/security.md.🛡️ License Management, HWID Binding & Analytics API Suite
Complete documentation for License Lifecycle Management, HWID Hardware Fingerprint Binding, IP/HWID Resets, Quotas, and System-Wide Analytics.
1. Authentication & Security Headers
All administrative API endpoints require Bearer token authorization in request headers:
Authorization: Bearer <ADMIN_API_TOKEN>
# Or via custom header:
X-GitPHP-Token: <ADMIN_API_TOKEN>
📋 2. Endpoints Reference Table
| Method | Endpoint Route | Description & Action |
|---|---|---|
POST | /api/v1/licenses | Generate a new server license key |
GET | /api/v1/licenses | List and search licenses (Paginated) |
GET | /api/v1/licenses/stats | System-wide license & device analytics |
GET | /api/v1/licenses/{id_or_key} | Retrieve single license & bound HWID devices |
PUT | /api/v1/licenses/{id_or_key} | Update customer info, plan, extend expiration |
POST | /api/v1/licenses/{id_or_key}/status | Change status (active, suspended, revoked) |
DELETE | /api/v1/licenses/{id_or_key} | Delete license record & device bindings |
GET | /api/v1/licenses/{id_or_key}/devices | List bound hardware fingerprints / devices |
DELETE | /api/v1/licenses/{id_or_key}/devices/{machine_id} | Unbind / revoke specific device HWID slot |
POST | /api/v1/licenses/{id_or_key}/reset-bindings | Reset all HWID bindings & IP for server migration |
💻 3. Ready-to-Use cURL Examples
Create Monthly License (30 Days):
curl -s -X POST https://git.ysnapp.com/api/v1/licenses -H "Authorization: Bearer <TOKEN>" -H "Content-Type: application/json" -d '{
"customer_name": "MUHAMMED GAILAN",
"plan_type": "monthly",
"duration_days": 30,
"max_devices": 2,
"bound_ip": "169.58.135.161",
"notes": "VIP Client"
}'
Get System Analytics:
curl -s -H "Authorization: Bearer <TOKEN>" https://git.ysnapp.com/api/v1/licenses/stats
Reset Device Bindings for Migration:
curl -s -X POST -H "Authorization: Bearer <TOKEN>" https://git.ysnapp.com/api/v1/licenses/FF-ED54-0CED-F732/reset-bindings
📕 4. Response Models & Error Dictionary
ERR_UNAUTHORIZED(401): Missing or invalid Bearer token.ERR_LIC_NOT_FOUND(404): Target license key or ID does not exist.ERR_LIC_EXPIRED(403): License validity period has expired.ERR_LIC_REVOKED(403): License has been banned or revoked by admin.ERR_LIC_DEVICE_LIMIT(403): Maximum allowed active hardware devices quota exceeded.ERR_LIC_HWID_CLONED(409): Duplicate machine ID or cloned hardware collision.
18 Troubleshooting
write scope, or check that your web server passes the Authorization header (see docs/deploy.md).php bin/fix-push.php to set 0660 permissions on authorized_keys.maxReqBodySize and reqTimeout in OpenLiteSpeed configuration (see docs/openlitespeed.conf).