# How to build blender (as python module) without having to clone the complete repository?

I'd like to build Blender v3.0.0 as a python module in a docker container. Generally, the process seems to be pretty straight-forward, thanks to the multitude of tutorials.

However, cloning the blender repository with

git clone https://git.blender.org/blender.git

takes a very long time. I thought that I could speed it up by making only a shallow clone of the repository using

git clone -b v3.0.0 --single-branch https://git.blender.org/blender.git or

git clone https://github.com/blender/blender.git --depth 1 --branch v3.0.0

but that gives me the following error during make update:

Blender git repository is in detached HEAD state, must be in a branch

Is there a way around this?

• How about you create a branch after cloning the repo? like git checkout -b my-branch ? Dec 15, 2021 at 20:34
• Well... I think that fixed it. :-) That was easier than suspected. I think I misinterpreted the error... Thank you very much. If you write an answer (maybe with a short explanation), then I'll be happy to accept it.
– Nos
Dec 15, 2021 at 23:03
• Thanks. I just posted it as an answer, using a different but equivalent command, as found in git documentation. Dec 16, 2021 at 8:25

It appears that Blender's build process depends on a the git repository being checked out to a branch.

In Blender's git repository, v3.0.0 is a tag, rather than a branch.

The shallow clone works with tags, but once it finishes, the local repository is not checked out to any actual git branch, hence the error message about detached HEAD state (c.f. git documentation on checking-out tags).

To solve the problem, simply create a branch, with the current contents of the repo.

For example:

git switch -c <new-branch-name>


Then, you should be good to go :)