{"id":50968859,"url":"https://github.com/chanware/git-safe-init","last_synced_at":"2026-06-18T23:32:35.137Z","repository":{"id":293576349,"uuid":"984488395","full_name":"chanware/git-safe-init","owner":"chanware","description":"Script which acts as a safety wrapper for 'git init' that prevents accidental repository initialization in the wrong directory. Works as a proper Git subcommand.","archived":false,"fork":false,"pushed_at":"2025-05-16T02:44:03.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-16T03:25:45.887Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chanware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-16T02:41:53.000Z","updated_at":"2025-05-16T02:45:21.000Z","dependencies_parsed_at":"2025-05-16T03:25:54.910Z","dependency_job_id":"7e7fd5be-6964-4098-a5a0-d9c1a45bd3e2","html_url":"https://github.com/chanware/git-safe-init","commit_stats":null,"previous_names":["chanware/git-safe-init"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chanware/git-safe-init","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanware%2Fgit-safe-init","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanware%2Fgit-safe-init/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanware%2Fgit-safe-init/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanware%2Fgit-safe-init/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chanware","download_url":"https://codeload.github.com/chanware/git-safe-init/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanware%2Fgit-safe-init/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34511617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-18T23:32:34.361Z","updated_at":"2026-06-18T23:32:35.130Z","avatar_url":"https://github.com/chanware.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛡️ git-safe-init\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![Shell: Zsh](https://img.shields.io/badge/Shell-Zsh-green.svg)](https://www.zsh.org/)\n[![Git Extension](https://img.shields.io/badge/Git-Extension-f05032.svg?logo=git)](https://git-scm.com/)\n\nA safety wrapper for `git init` that prevents common mistakes.\n\n## What Problem Does This Solve?\n\nIf you've ever accidentally initialized a git repository in the wrong directory (like your parent \"repos\" folder), you know the headache that follows. This script adds a confirmation layer to prevent those mistakes.\n\n## Features\n\n- Detects if you're already inside an existing git repo\n- Shows your current working directory for verification\n- Requires explicit confirmation before proceeding\n- Works as a proper git subcommand (`git safe-init`)\n- Includes visual formatting to highlight important information\n\n## Installation\n\n### Option 1: Direct Download\n\n1. Create a personal bin directory (if you don't already have one):\n   ```bash\n   mkdir -p ~/bin\n   ```\n   \u003e The `-p` flag creates parent directories as needed and doesn't error if the directory already exists - helpful for idempotent scripts.\n\n2. Download the script:\n   ```bash\n   curl -o ~/bin/git-safe-init https://raw.githubusercontent.com/chanware/git-safe-init/main/git-safe-init.sh\n   ```\n\n3. Make it executable:\n   ```bash\n   chmod +x ~/bin/git-safe-init\n   ```\n\n4. Ensure ~/bin is in your PATH:\n   ```bash\n   # Check if it's already there\n   echo $PATH | grep -q \"$HOME/bin\" \u0026\u0026 echo \"Already in PATH\" || echo \"Not in PATH\"\n   \n   # Add to PATH if needed (for zsh)\n   echo 'export PATH=\"$HOME/bin:$PATH\"' \u003e\u003e ~/.zshrc\n   source ~/.zshrc\n   ```\n\n### Option 2: Clone the Repo\n\n1. Clone this repository:\n   ```bash\n   git clone https://github.com/chanware/git-safe-init.git\n   ```\n\n2. Create a symlink to your bin directory:\n   ```bash\n   mkdir -p ~/bin\n   ln -s \"$(pwd)/git-safe-init/git-safe-init.sh\" ~/bin/git-safe-init\n   ```\n\n3. Ensure ~/bin is in your PATH (see Option 1, step 4)\n\n## Usage\n\nSimply run:\n```\ngit safe-init\n```\n\n| Command | Safety | Status |\n|---------|--------|--------|\n| `git safe-init` | With confirmation | ✅ Safe |\n| `git init` | No safety checks | ⚠️ Use with caution |\n\n### Example Output\n\nWhen run in a new directory:\n```\nYou are in: /Users/you/projects/new-project\nAre you SURE you want to 'git init' here? (y/n): y\nInitialized empty Git repository in /Users/you/projects/new-project/.git/\n```\n\nWhen already inside a git repository:\n```\nError: This folder is already part of a git repository.\nUse git status to check.\n```\n\n## How It Works\n\nThis uses Git's subcommand mechanism, where executables named `git-*` in your PATH become available as `git *` commands. The script performs safety checks before delegating to the actual `git init` command.\n\n## Why Not Just an Alias?\n\nWhile you could create a shell alias, this approach:\n- Works consistently across different shell environments\n- Follows Git's established extension pattern\n- Is easier to share with others\n- Doesn't require modifying shell configs on each machine\n\n## Technical Notes\n\nThe script uses zsh by default. If you prefer bash, change the shebang line from `#!/bin/zsh` to `#!/bin/bash` and modify the color formatting.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanware%2Fgit-safe-init","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchanware%2Fgit-safe-init","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanware%2Fgit-safe-init/lists"}