Git branch -d <BRANCH>: Fatal - Could not find commit object for HEAD

Say I'm in an open repository (remote), if I try to delete a branch with git branch -d <branch_name> , I get the following error:

 fatal: Couldn't look up commit object for HEAD 

Why? Is there a reason why I cannot delete branches from open storage?

+7
source share
4 answers

Make sure capitol D used in the command, in which case you should enter git branch -D <branch_name> . Please note: this will only remove the branch from your local computer.

If you are trying to remove the remote branch, type git push origin :<branch_name> (don't forget to add a colon)

+13
source

To avoid this confusion, you can use

"git push origin --delete information_name

Deletes the remote branch, not the local branch.

+2
source

Locate the .git / refs / heads / branch_name file in Windows Explorer and delete it directly.

+1
source

This only happens when the default branch (which the HEAD branch points to in an empty repository folder - usually master ) does not exist locally. If it exists, you can delete a branch with branch -d even from an empty repository folder (-d if it is merged).

If you work with git working trees, the execution of a command from the working tree may be successful (the same condition must be met as for the HEAD of the working tree)

0
source

Source: https://habr.com/ru/post/1481767/


All Articles