find-remote-repo-on-local
v1.0.1
Published
Node.js script to find local instances of remote GitHub repositories
Maintainers
Readme
Find Remote Repo on Local
A Node.js tool to find local instances of remote GitHub repositories in a directory and its subdirectories.
Features
- Search for local git repositories that match a given GitHub remote URL
- Support for both HTTPS and SSH GitHub URLs
- Recursive directory traversal
- Colored output for better readability
- Cross-platform compatibility
Installation
Global Installation (Recommended)
npm install -g find-remote-repo-on-localAfter installation, you can use the command find-repo from anywhere.
Using npx (No Installation)
npx find-remote-repo-on-local <github-repo-url> [search-directory]Usage
# If installed globally:
find-repo https://github.com/user/repo
# If using npx:
npx find-remote-repo-on-local https://github.com/user/repo
# Search in specific directory
find-repo https://github.com/user/repo /path/to/search
# Works with SSH URLs too
find-repo [email protected]:user/repo.git
# Works with various URL formats
find-repo user/repoURL Format Support
The script supports various GitHub URL formats:
https://github.com/user/repohttps://github.com/user/repo.git[email protected]:user/repo.gituser/repo(automatically converted to HTTPS)
Output
The script will:
- Display the search parameters (target URL, repository name, search directory)
- Search through all subdirectories for
.gitfolders - Check remote URLs in each git repository
- Display matches with full path and remote URL
- Show a summary of how many matches were found
Example Output
Searching for repositories matching: https://github.com/user/example-repo
Repository name: example-repo
Search directory: /Users/username/projects
✓ Found match:
Path: /Users/username/projects/my-projects/example-repo
Remote URL: https://github.com/user/example-repo.git
✓ Found match:
Path: /Users/username/projects/backups/example-repo-backup
Remote URL: [email protected]:user/example-repo.git
Found 2 local instance(s) of the repository.Requirements
- Node.js (v12.0.0 or higher)
- Git installed and available in PATH
Exit Codes
0- Success (found at least one matching repository)1- No matches found or error occurred
Notes
- The script normalizes URLs for comparison, so it can match repositories regardless of whether they use HTTPS or SSH URLs
- Hidden directories (starting with
.) are generally skipped, except for.gitdirectories - The script handles permission errors gracefully and continues searching
License
MIT
