Skip to content

Instantly share code, notes, and snippets.

@metinsenturk
Last active December 5, 2018 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metinsenturk/ed37f8f74307c9df48b002e93df292e9 to your computer and use it in GitHub Desktop.
Save metinsenturk/ed37f8f74307c9df48b002e93df292e9 to your computer and use it in GitHub Desktop.
Git replacing origin master with local master
#!/bin/bash
# replace origin/master branch with a local branch named as 'otherbranch', with force.
git push origin otherbranch:master -f
# list remote branch
git remote -v
# replace remote branch with another remote branch
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
# push the branch to remote
git push origin BRANCH
# set branch upstream on remote
git branch --set-upstream-to=origin/BRANCH BRANCH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment