Search code examples
gitgit-checkoutgit-fetch

Unable to fetch the branch since the reference branches are deleted


I was trying to pull git branch bugfix/validator-integration-bugfix using following command git fetch && git checkout bugfix/validator-integration-bugfix

but I am getting following error:

akshaykhale$ git fetch && git checkout bugfix/validator-integration-bugfix
error: cannot lock ref 'refs/remotes/origin/bugfix/connection-failure-bugfix': 'refs/remotes/origin/bugfix' exists; cannot create 'refs/remotes/origin/bugfix/connection-failure-bugfix'
From https://github.com/luxio/luxio-framework
 ! [new branch]          bugfix/connection-failure-bugfix -> origin/bugfix/connection-failure-bugfix  (unable to update local ref)
error: cannot lock ref 'refs/remotes/origin/bugfix/migration-datatype-bugfix': 'refs/remotes/origin/bugfix' exists; cannot create 'refs/remotes/origin/bugfix/migration-datatype-bugfix'
 ! [new branch]          bugfix/migration-datatype-bugfix                  -> origin/bugfix/migration-datatype-bugfix  (unable to update local ref)
error: cannot lock ref 'refs/remotes/origin/bugfix/validator-integration-bugfix': 'refs/remotes/origin/bugfix' exists; cannot create 'refs/remotes/origin/bugfix/validator-integration-bugfix'
 ! [new branch]          bugfix/validator-integration-bugfix                           -> origin/bugfix/validator-integration-bugfix  (unable to update local ref)

Possible reason could be (just a guess):

I am fetching bugfix/validator-integration-bugfix branch which is created from other branches which were not cloned on my development system.

any way to fix the issue

Thanks in advance!!!


Solution

  • Following worked for me:

    git fetch --prune
    

    With git prune it pulled all the branches, I could switch to the required branch and able to push in the commits without any issues.

    Thank you @MarkAdelsberger