Hone

Lessons · Git · the branch it tracked is gone

The branch it tracked is gone

'gone' means the remote branch your local branch tracks no longer exists. Your branch and its commits are untouched; what is missing is the thing it was compared against.

Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.

What it is for

It usually means the pull request was merged and the branch tidied up, and it usually means nothing is wrong.

How to think about it

fetch --prune is what makes git notice. Then check whether the commits are actually merged before deleting anything.

Worked example

git branch -vv
It still thinks origin/feature is there, because nothing has looked.
git fetch -q --prune origin
Now it looks, and removes what is no longer on the remote.
git branch -vv
origin/feature: gone.
git log --oneline
And your commit is exactly where it was.
git branch --merged main
The question worth asking before deleting: is the work actually in main?

Your turn

Fetch, and drop remote-tracking branches that no longer exist.

git fetch  origin

The trap

Reading 'gone' as 'merged'. It can also mean somebody closed the pull request and tidied up, and the work is only on your machine.

Practise the branch it tracked is gone on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.