Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 1.09 KB

move-one-repo-to-another.adoc

File metadata and controls

46 lines (35 loc) · 1.09 KB

Move one repository to another

Note
Github and other public source code repositories have convenient features to do all of this without bothering with git (rename, transfer ownership, …​) but you have to remain within the platform.

First of all, clone the existing repository:

git clone <old-repo>

Set remote origin to the new repository:

git remote set-url origin <new-repo>

Prune the existing remote branches:

git remote prune origin

When done, it is possible to adapt the repo in order to:

Last but not least, make all the existing branches track branches in the new repository while pushing them:

git checkout <branch-name>
git push --set-upstream origin "<branch-name>"

Using prezto aliases:

# Clone old repo
gfc <old-repo>
# Set remote to the new repo
gR set-url origin <new-repo>
# Prune existing remote branches
gRp

# Do any update you want

# Track branches while pushin them
gco <branch-name>
gpc