2

I've been trying to finish the migration of our old TFVC sources using Git-TFS. It has finally seemed to work but after renaming the automatically created "master" branch (aka making a new one from it and changing the Default branch in Azure DevOps) no one can push anymore. I tried various things I found online nothing has seemed to work. The old branch's name was "master", the new branch's name is "Head/Main".

These are the results I get:

  • git checkout Head/Main : Works.

  • git gc --prune=now : "fatal: bad object refs/remotes/origin/HEAD fatal: failed to run repack"

  • git remote prune origin: Works but nothing changes.

  • git push : fatal: The current branch Head/Main has no upstream branch. (I removed it earlier, trying to reset it)

  • git push -u origin : "Updates were rejected because the tip of your branch is behind its remote counterpart" - This is expected as there are changes on the remote that I do not yet have locally.

  • git branch --set-upstream-to=origin/Head/Main : error: cannot lock ref 'refs/remotes/origin/Head/Main': unable to resolve reference 'refs/remotes/origin/Head/Main';

  • Content of /.git/refs/remotes/origin/HEAD : ref: refs/remotes/origin/Head/Main

  • git pull origin Head/Main : * branch Head/Main -> FETCH_HEAD
    error: cannot lock ref 'refs/remotes/origin/Head/Main': unable to resolve reference 'refs/remotes/origin/Head/Main'
    ! 009ac793a8..9bcff8c144 Head/Main -> origin/Head/Main (unable to update local ref)

Quite frankly, I have no clue what I can do to fix this, please help :x

Vaethin
  • 316
  • 4
  • 18
  • I suggest that you remove '/' from the branch name. It works in a few of git operations and fails in others. – Serge Jan 30 '20 at 19:40
  • `HEAD` is a [keyword](https://stackoverflow.com/questions/2304087/what-is-head-in-git) in git and I would refrain from using it in branch names, it's likely to be causing the issue at hand. – Emil Kantis Jan 30 '20 at 23:21
  • I managed to fix the issue by deleting the contents of the refs and logs folder in the .git directory. Then I checked out Head/Main and used git branch --set-upstream-to=origin/Head/Main .... – Vaethin Jan 31 '20 at 09:34
  • The weird part is that everyone who freshly clones the repository has the same misconfiguration and I don't know how I can fix it on the remote? – Vaethin Jan 31 '20 at 09:36

1 Answers1

-2

Short Answer:

git checkout master, then reset master back to be the default, and move on.

People need to adapt the new terminology, especially that GIT is the new VC mentality and the term "master" is used in every documentation.

P.S You can't imagine what a / would do in a branch name. Or maybe you could by now?

Sandra K
  • 1,209
  • 1
  • 10
  • 21