git-repo-name
is a CLI tool that syncs your local git directory name with the remote repository name.
It works bi-directionally and supports these two main use cases:
- When you rename a repo on GitHub, run
git-repo-name pull
to update the local git directory name. - When you rename a local git directory, run
git-repo-name push
to rename the repo on GitHub.
In both cases, it makes an API call to GitHub, compares the repo name to the local directory name, and automatically renames the appropriate side.
git-repo-name
provides four main commands:
git-repo-name pull # Fetches repo name from the remote and renames local git directory name to match it
git-repo-name push # Renames repo name on the remote with the local git directory name
git-repo-name fetch # Fetches repo name from the remote without making changes
git-repo-name config # Configures settings (GitHub token and default remote)
Fetches repo name from the remote and renames local git directory name to match it.
Note: For private GitHub repos, this requires a GitHub PAT (see Configuration Keys for more details).
Examples
# Basic usage
git-repo-name pull
# Specify a remote [default: origin]
git-repo-name pull -r upstream
# Preview what would happen without making changes
git-repo-name pull -n
Renames repo name on the remote with the local git directory name.
Note: For GitHub repos, this requires a GitHub PAT (see Configuration Keys for more details).
Examples
# Basic usage
git-repo-name push
# Specify a remote [default: origin]
git-repo-name push -r upstream
# Preview what would happen without making changes
git-repo-name push -n
Fetches repo name from the remote without making changes.
Examples
# Basic usage
git-repo-name fetch
# Specify a remote [default: origin]
git-repo-name fetch -r upstream
Configures settings.
-
default-remote
: The remote to use when none is specified (defaults to "origin")Examples:
# View default remote git-repo-name config default-remote # Set default remote git-repo-name config default-remote upstream
-
github-token
: GitHub personal access token for authenticating GitHub API requests.Note: See the table below to determine the type of GitHub token you need and the permissions required.
Scenario PAT type Permissions required Public repositories ( pull
/fetch
only)N/A (no token required) None Private repositories owned by you Fine-grained Metadata (read) for pull
/fetch
; Administration (write) forpush
Organization repositories Classic repo scope Mixed personal & organization repositories Classic repo scope Examples:
# View GitHub token git-repo-name config github-token # Set GitHub token git-repo-name config github-token ghp_your_token_here
-
Install the
git-repo-name
formula:brew tap petrgazarov/git-repo-name brew install git-repo-name
-
Add the following line to your shell startup file (e.g.,
~/.bashrc
or~/.zshrc
):source "$(brew --prefix)/share/git-repo-name/git-repo-name.sh"
Pre-compiled binaries are available on the Releases page.
When downloading binaries directly, you'll need to manually set up shell integration:
-
Download both the binary and the shell script from the releases page
-
Make both files executable using:
chmod +x /path/to/git-repo-name-bin /path/to/git-repo-name
-
Place the binary in your PATH as
git-repo-name-bin
-
Place the shell script in your PATH as
git-repo-name
-
Add the following line to your shell startup file (e.g.,
~/.bashrc
or~/.zshrc
):source "$(which git-repo-name)"
Alternatively, you can clone this repository and build from source using Cargo:
-
Install and build the binary:
cargo install --git https://github.com/petrgazarov/git-repo-name.git
-
Rename the cargo-installed binary:
mv $(which git-repo-name) $(dirname $(which git-repo-name))/git-repo-name-bin
-
Download the shell script from the repository and make it executable:
curl -o /usr/local/bin/git-repo-name https://raw.githubusercontent.com/petrgazarov/git-repo-name/main/git-repo-name.sh chmod +x /usr/local/bin/git-repo-name
Replace
/usr/local/bin
with your preferred installation directory (ensure it's in your PATH). -
Add the following line to your shell startup file (e.g.,
~/.bashrc
or~/.zshrc
):source "$(which git-repo-name)"
git-repo-name
currently supports GitHub and file (bare) remotes.