Skip to content

Instantly share code, notes, and snippets.

@hypnoJerk
Last active April 5, 2022 19:37
Show Gist options
  • Save hypnoJerk/8caf71902194292b4c679b6ab7b09726 to your computer and use it in GitHub Desktop.
Save hypnoJerk/8caf71902194292b4c679b6ab7b09726 to your computer and use it in GitHub Desktop.
Push Existing Local Branch to Remote Master on New Github Repository

check remote

git remote -v

remove old remote

git remote rm <remote-name>

check remote that its gone

git remote -v

git add new origin and push

git push <https github link to repository> +<local branch name>:<remote branch name>

For Example: git push https://github.com/hypnoJerk/effective-octo-lamp.git +devbranch:master

Add New Remote Origin

git remote add origin <https github link>

delete the old master branch

git branch -d master

Download master from remote

git fetch

Switch to master branch

git checkout master

You now have two local branches (one master, one your starting branch) and they match two branches on remote with the same name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment