Renaming Git repository during clone

Greg Foster
Greg Foster
Graphite software engineer

Guide to renaming a repository during cloning with Git

Sometimes you may need to clone a repository into a directory with a different name than the original repository, effectively renaming the repository locally. This guide will walk you through how to rename a repository during the cloning process using the git clone command, covering various scenarios and best practices.

The git clone command is used to create a copy of an existing repository into a new directory on your local machine. The basic syntax of the command is:

git clone [repository URL]

By default, Git names the directory that the repo is cloned into after the name of the remote repository. However, you can specify a different directory name directly in the command to change this behavior.

To clone a repository and rename it simultaneously, you simply specify the new directory name at the end of the clone command. You can do this by running:



  • <REPOSITORY_URL> is the URL of the repository you want to clone.
  • <NEW_DIRECTORY_NAME> is the name of the directory into which you want the repository to be cloned.
  1. Locate the repository URL: First, you need to obtain the URL of the repository you wish to clone. This can typically be found on the repository's page on GitHub, GitLab, Bitbucket, or your self-hosted Git server.

  2. Decide on a new folder name: Choose a new name for the folder that will contain the cloned repository. This name can be anything that suits your project organization or naming conventions.

  3. Run the clone command with a new name: Open your terminal or command prompt and run the git clone command with the repository URL followed by your chosen new folder name. For example:

    git clone new-repo-name

    This command clones the repository located at into a local directory named new-repo-name.

  • Organizational purposes: When you are managing multiple versions of a repository or similar projects, renaming them appropriately during cloning helps keep your directories organized and understandable.
  • Avoiding naming conflicts: If you already have a directory with the same name as the repository you’re cloning, renaming it during cloning avoids conflicts and the need for manual renaming later.
  • Consistent naming conventions: Stick to a consistent naming convention for your local directories to make it easier to navigate and manage your projects.
  • Check existing directories: Before cloning, check if the chosen directory name exists to avoid unintentional overwriting.
  • Understand Git behavior: Remember that renaming a directory during cloning only affects the local folder name, not the repository name on the server. The remote repository's name remains unchanged.

For further reading on cloning repositories in Git, see the official documentation.

Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Get started

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2