Skip to content

Instantly share code, notes, and snippets.

@jamiejohnsonkc
Last active September 9, 2021 15:57
Show Gist options
  • Save jamiejohnsonkc/073ed88464adbf224c179d489125832a to your computer and use it in GitHub Desktop.
Save jamiejohnsonkc/073ed88464adbf224c179d489125832a to your computer and use it in GitHub Desktop.
git clone & create new repo

First clone the repository you want to work with. This step could be skipped if you want it all to happen in the folder you are already in.

git clone file:///path/to/repo/

Cloning will bring over the remotes specified in that directory. So you'll need to remove the remotes you don't want.

git remote rm <remote>

And add the ones you do, after you have created your remote repository.

git remote add origin <url>

You will also want to --set-upstream-to, or -u to tell git this is the remote repository this branch will update to, presuming you are on the main (or default) branch.

git push -u origin main

Then you'll need to decide which branches to keep and add to the remote. If you want to push all of them, just do git push --mirror. This will push all your tags and your remotes. But since we edited your remotes in an earlier step, it shouldn't be a problem.

If you only want to keep a few, you can

git push -u origin <branch> each one you want.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment