Bad default revision ‘head’

HEAD

Git reported the above error, which literally means “wrong default version of head”. Let’s figure out what head is. The GIT manual says:

The head file is a symbolic reference to the branch you’re currently on. By symbolic reference, we mean that unlike a normal reference, it doesn’t generally contain a SHA-1 value but rather a point to another reference.
the head file is a symbolic reference to the current branch. By symbolic reference, we mean that, unlike a normal reference, it usually does not contain a SHA-1 value, but a pointer to another reference.

In short, the head file points to the current branch. If you do not create a custom branch, head points to the Master branch by default. Open the head file, and you can see:

$ cat .git/HEAD
ref: refs/heads/master

The head file is a link file of the file refs / heads / Master . When we create a new user-defined branch, such as dev , switch to the branch and submit the modification under the branch, head points to the branch where the modification was made dev , and open the head file

$ cat .git/HEAD
ref: refs/heads/dev

Therefore, GIT reports an error bad default revision 'head' , which means that the current branch of head is wrong.

terms of settlement

    Modify symbolic links

    You can also manually edit this file, but again a safer command exists to do so: symbolic ref .
    you can modify the head file manually, but there is a more secure command to do it: symbolic Ref.

    for example, I changed head from pointing to Master to pointing to dev :

    git symbolic-ref HEAD refs/heads/dev
    

    Switch branches and submit again

    reference resources

    Git: fatal: bad default revision ‘head’ git internal – git references creating and merging branches – Liao Xuefeng git tutorial

Read More: