SOLVED: Git remote ref does not exist when trying to delete branches

git-icon

The problem

Today, I was updating an old git repository but when I tried to delete some branches in my local environment and in the remote, I received this kind

“remote ref does not exist”

And that is because some remote branches didn’t exist anymore.

Solution

In order to update the references in our local machine we can use the git fetch command in this format:

git fetch -p MY_REMOTE

// Example
git fetch -p origin

From Stack Overflow:

“The -p option tells fetch to delete any tracking branches that no longer exist in the corresponding remotes; by default they are kept around”.

That’s it for today enjoy your work!

One comment on “SOLVED: Git remote ref does not exist when trying to delete branches”

Leave a Reply

Your email address will not be published. Required fields are marked *