Skip to content

Instantly share code, notes, and snippets.

@okram999
Created May 23, 2016 21:59
Show Gist options
  • Save okram999/ba7af7265b5e545aaead6caf04f39980 to your computer and use it in GitHub Desktop.
Save okram999/ba7af7265b5e545aaead6caf04f39980 to your computer and use it in GitHub Desktop.
# Fetch all of the remote branches and tags:
git fetch origin
# View all "old repo" local and remote branches:
git branch -a
# If some of the remotes/ branches doesn't have a local copy,
# checkout to create a local copy of the missing ones:
git checkout -b <branch> origin/<branch>
# Now we have to have all remote branches locally.
### Step 2. Add a "new repo" as a new remote origin:
git remote add new-origin [email protected]:user/repo.git
### Step 3. Push all local branches and tags to a "new repo".
# Push all local branches (note we're pushing to new-origin):
git push --all new-origin
# Push all tags:
git push --tags new-origin
### Step 4. Remove "old repo" origin and its dependencies.
# View existing remotes (you'll see 2 remotes for both fetch and push)
git remote -v
# Remove "old repo" remote:
git remote rm origin
# Rename "new repo" remote into just 'origin':
git remote rename new-origin origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment