Mittwoch, 19. Juli 2023

Laravel Forge: fatal: couldn't find remote ref refs/heads

On Laravel Forge I checked out a branch and deleted it from the git server by accident. Now I can not fetch and can not switch branch. Fun fact Forge tells me it switched while it did not:

forge@myserver:~/myserver.de$ git fetch 

fatal: couldn't find remote ref refs/heads/mybranch

fatal: the remote end hung up unexpectedly

This can be fixed be open and edit .git/config

In remote section replace the checked out branch mybranch with * two times:

[remote "origin"]

    url = git@bitbucket.org:me/mygit

--  fetch = +refs/heads/mybranch:refs/remotes/origin/mybranch 

++  fetch = +refs/heads/*:refs/remotes/origin/*

Save and quite.

Now you can run "git fetch" and "git checkout main".

I also deleted the old branch: git branch -d mybranch 


Keine Kommentare: