gdit
v3.0.2
Published
π Git-like version control for Google Drive. Stage, commit, and sync files using familiar Git commands.
Maintainers
Readme
π gdit
Git-like Version Control for Google Drive
Stage β’ Commit β’ Push to Google Drive
Installation β’ Quick Start β’ Commands β’ How It Works β’ Contributing
π― What is gdit?
gdit is a command-line tool that brings familiar Git-like workflows to Google Drive. If you know Git, you already know gdit!
# Just like Git, but for Google Drive!
gdit add .
gdit commit -m "Add new feature"
gdit push⨠Key Features
| Feature | Description |
|---------|-------------|
| π¦ Stage & Commit | Stage files and commit with messages, just like Git |
| π Smart Sync | Only uploads changed files (compares MD5 hashes) |
| β¬οΈ Pull & Clone | Download files from Drive or clone existing folders |
| π Status & Diff | See what's changed between local and remote |
| π Commit History | View your commit log with push status |
| π― Ignore Files | Support for .gditignore (like .gitignore) |
| π Secure | OAuth 2.0 authentication, tokens stored locally |
| π¨ Beautiful CLI | Colorful output with spinners and progress bars |
π¦ Installation
npm install -g gditRequirements:
- Node.js 18 or higher
- A Google Cloud project (free)
π Quick Start
Step 1: Set Up Google Credentials (One-time)
gdit setup-credsThis guides you through creating OAuth credentials. You'll need to:
- Go to Google Cloud Console
- Create a project (or use existing)
- Enable the Google Drive API
- Create OAuth 2.0 credentials (Desktop app)
- Copy your Client ID and Client Secret
Step 2: Login
gdit loginA browser window opens for Google authentication. After approval, you're ready!
Step 3: Initialize & Sync
# Create a new project
mkdir my-project && cd my-project
# Initialize gdit (creates a Drive folder)
gdit init
# Add all files
gdit add .
# Commit your changes
gdit commit -m "Initial commit"
# Push to Google Drive
gdit pushπ That's it! Your files are now synced to Google Drive.
π Commands
π§ Setup Commands
| Command | Description |
|---------|-------------|
| gdit setup-creds | Configure Google API credentials (one-time) |
| gdit login | Authenticate with Google |
| gdit logout | Remove stored tokens |
| gdit whoami | Show current user info and storage usage |
π Repository Commands
| Command | Description |
|---------|-------------|
| gdit init | Initialize a new repository (creates Drive folder) |
| gdit clone <folder-id> | Clone an existing Drive folder |
| gdit remote | Show remote folder info |
| gdit remote open | Open Drive folder in browser |
π¦ Working with Files
| Command | Description |
|---------|-------------|
| gdit add <files...> | Stage specific files |
| gdit add . | Stage ALL files |
| gdit rm <files...> | Unstage files |
| gdit reset | Clear the staging area |
π Commits & Syncing
| Command | Description |
|---------|-------------|
| gdit commit -m "message" | Commit staged files |
| gdit amend -m "message" | Change last commit message |
| gdit push | Push commits to Google Drive |
| gdit push -f | Force push ALL files |
| gdit pull | Download files from Drive |
| gdit pull --theirs | Always use remote version (conflicts) |
| gdit pull --ours | Always keep local version (conflicts) |
π Information
| Command | Description |
|---------|-------------|
| gdit status | Show repository status |
| gdit log | View commit history |
| gdit log --files | Show files in each commit |
| gdit log -n 5 | Show last 5 commits |
| gdit diff | Compare local vs remote files |
π§ How It Works
Architecture Overview
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β YOUR COMPUTER β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β my-project/ ~/.gdit/ β
β βββ .gdit/ ββββββββΊ βββ credentials.json β
β β βββ config.json βββ token.json β
β β βββ stage.json (global auth) β
β β βββ commits.json β
β β βββ remote.json β
β βββ src/ β
β β βββ index.ts β
β βββ package.json β
β β
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
β gdit push / pull
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GOOGLE DRIVE β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β π my-project/ β
β βββ π src/index.ts β
β βββ π package.json β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββWorkflow Diagram
βββββββββββββββ gdit add βββββββββββββββ gdit commit βββββββββββββββ gdit push βββββββββββββββ
β Working β βββββββββββββββΊ β Staging β βββββββββββββββΊ β Commits β βββββββββββββΊ β Google β
β Directory β β Area β β (Local) β β Drive β
βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββ
β β
β gdit pull β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββSmart Sync
gdit uses MD5 checksums to detect changes:
$ gdit push
[1/3] Processing src/index.ts...
β Already up to date: src/index.ts # Hash matches, skip
[2/3] Processing package.json...
β Updated: package.json # Hash differs, upload
[3/3] Processing README.md...
β Created: README.md # New file, create
π Push Summary
ββββββββββββββββββββ
β New files: 1
β» Updated: 1
β Skipped: 1π Project Structure
gdit/
βββ src/ # TypeScript source code
β βββ index.ts # CLI entry point
β βββ types/ # Type definitions
β β βββ index.ts # All TypeScript interfaces
β βββ core/ # Core functionality
β β βββ config.ts # Paths and constants
β β βββ auth.ts # Google OAuth
β β βββ drive.ts # Drive API operations
β βββ commands/ # CLI commands
β β βββ init.ts # gdit init
β β βββ stage.ts # gdit add/rm/reset
β β βββ commit.ts # gdit commit/amend
β β βββ push.ts # gdit push
β β βββ pull.ts # gdit pull/clone
β β βββ status.ts # gdit status/log/diff
β β βββ info.ts # gdit whoami/remote
β βββ utils/ # Utilities
β βββ ui.ts # Terminal output
β βββ prompts.ts # User input
β βββ files.ts # File operations
βββ dist/ # Compiled JavaScript
βββ package.json # Dependencies
βββ tsconfig.json # TypeScript config
βββ README.md # You're reading it!π Ignoring Files
Create a .gditignore file in your project root:
# Dependencies
node_modules
# Build output
dist
*.min.js
# IDE
.vscode
.idea
# OS files
.DS_Store
Thumbs.db
# Logs
*.log
npm-debug.log*
# Environment
.env
.env.localDefault ignored patterns:
.gdit/(gdit config).git/(git directory)node_modules/- Hidden files (starting with
.)
π Security
Where are my credentials stored?
| File | Location | Contains |
|------|----------|----------|
| credentials.json | ~/.gdit/ | Your OAuth Client ID & Secret |
| token.json | ~/.gdit/ | OAuth access & refresh tokens |
β οΈ Important
- Never share your
credentials.jsonortoken.json - Each user must create their own OAuth credentials
- Tokens are refreshed automatically when expired
Revoking Access
To revoke gdit's access to your Google account:
- Go to Google Account Security
- Find "gdit" in the list
- Click "Remove Access"
Then locally:
gdit logoutπ οΈ Development
Building from Source
# Clone the repository
git clone https://github.com/your-username/gdit.git
cd gdit
# Install dependencies
npm install
# Build TypeScript
npm run build
# Link for local testing
npm link
# Now you can use `gdit` globally
gdit --versionDevelopment Mode
# Watch mode - recompiles on changes
npm run devTesting
npm testπ€ Contributing
Contributions are welcome! Please read our Contributing Guide first.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
Built with these awesome libraries:
- Commander.js - CLI framework
- Chalk - Terminal colors
- Ora - Spinners
- Boxen - Boxes in terminal
- Figlet - ASCII art
- googleapis - Google APIs
Made with β€οΈ for developers who love both Git and Google Drive
