0

I have an repository in which the master branch was renamed to product. Things are fine except on one box where the code was cloned before this change. On that box HEAD still points to master:

* local-2
  remotes/origin/HEAD -> origin/master
  remotes/origin/local-1
  remotes/origin/product
  remotes/origin/local-2

It's certainly incorrect, but in practical application, it's also causing an issue with a deployment script. What would it take to reposition remotes/origin/HEAD so that it points to remotes/origin/product?

Rob Wilkerson
  • 37,910
  • 41
  • 130
  • 185

1 Answers1

3

These lines of output:

remotes/origin/HEAD -> origin/master
remotes/origin/product

say that the reference HEAD in your origin repo points to origin/master, but as you've said, origin/master has been renamed to origin/product. You'll need to do two things to correct this:

  1. Make the reference HEAD on origin point to product.
  2. Update local clones to have remotes/origin/HEAD point to origin/product.

For step #1, if your origin is hosted on GitHub, you simply set the default branch for origin to product. If it's not hosted on GitHub, you'll need access to the remote repo, from which you run the following:

git symbolic-ref HEAD refs/heads/product

For step #2, you'll need to run the following on each local clone to update what they have the remote repo HEAD configured to:

git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/product

See also:

  1. Official Linux Kernel Git documentation for git symbolic-ref.
  2. Git: Correct way to change Active Branch in a bare repository?.
  3. How do I change a Git remote HEAD to point to something besides “master”.
Community
  • 1
  • 1