It works:
:/tmp$ COMMIT_ID=`git ls-remote
">
:zynkmobile/resourcemanager.git develop`
:/tmp$ git clone
">
:zynkmobile/resourcemanager.git
Cloning into 'resourcemanager'...
remote: Counting objects: 1703, done.
remote: Compressing objects: 100% (729/729), done.
remote: Total 1703 (delta 1193), reused 1349 (delta 948)
Receiving objects: 100% (1703/1703), 20.07 MiB | 183 KiB/s, done.
Resolving deltas: 100% (1193/1193), done.
:/tmp$ cd resourcemanager/
:/tmp/resourcemanager$ git checkout -b deploy $COMMIT_ID
fatal: Cannot update paths and switch to branch 'deploy' at the same time.
Did you intend to checkout 'refs/heads/develop' which can not be resolved as commit?
:/tmp/resourcemanager$ echo $COMMIT_ID
af5c7ff84dd852cf1c0b5ca60ea92546a20dda01 refs/heads/develop
:/tmp/resourcemanager$ git checkout -b deploy `echo $COMMIT_ID | cut -d' ' -f1`
Switched to a new branch 'deploy'
:/tmp/resourcemanager$
Another interesting thing is that if I list branched on this manually cloned repo, here’s what I get:
:/tmp/resourcemanager$ git branch -a
* deploy
master
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/master
On the one that was cloned by Chef, on the other hand:
:/opt/apps/resourcemanager/shared/cached-copy$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
The develop branch is not present. My only guess is that Chef’s way of cloning does not clone the whole thing, and for some reason leaves the branch I need out.