Skip to content

Instantly share code, notes, and snippets.

@dominikwilkowski
Created March 20, 2025 00:51
Show Gist options
  • Save dominikwilkowski/246885a3340b0054057ef15e958387a0 to your computer and use it in GitHub Desktop.
Save dominikwilkowski/246885a3340b0054057ef15e958387a0 to your computer and use it in GitHub Desktop.
Clone a repo with all branches

Moving a repo

  1. Clone the repo with the --mirror flag
git clone --mirror https://<URL>.git
  1. Create a new repo without initializing it with any files
  2. Clone this new repo locally
  3. Add a new remote to the new repo
git remote add new_remote https://<URL>.git
  1. Push to the new remote
git push --mirror new_remote
  1. Remove the old remote
git remote rm origin

Additional

List all remotes:

git remote -v

Clones pointing to new remote:

git remote set-url origin https://<URL>.git

Renaming remotes:

git remote rename old_name new_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment