Search code examples
gitgit-remote

How to switch a remote repository to a different branch


I have three local and three remote branches and want to be on the same branch on both.

On local:

git branch
  A
* B
  master

git branch -r
  origin/A
  origin/B
  origin/master

On remote:

git branch
  A
  B
* master

I am able to commit, push and pull B, but my update hook deploys master instead of B. I suppose because the remote branch is still set to master. I created branch B using:

git branch B
git checkout B
git push origin B

Solution

  • As far as I know, there's no way to change a remote's current branch with git push. Pushing will just copy your local changes up into that repository. Typically remotes you push to should be --bare, without a working directory (and thus no "current branch").