Here is how to replicate the problem:

Setup remote repositories, e.g. in bitbucket:
For superproject: https://an...@bitbucket.org/anton/mysuperproject.git
For submodule: https://an...@bitbucket.org/anton/mysubmodule.git

Setup local repository for superproject:
git init mysuperproject
cd mysuperproject
echo "This is the parent project" > README
git add README
git commit -m "add README"
git remote add origin https://an...@bitbucket.org/anton/mysuperproject.git
git push --all -u origin

Setup local repository for submodule with branch "develop":
cd ..
git init mysubmodule
cd mysubmodule
echo "This is the submodule" > README
git add README
git commit -m "add README"
git branch develop master
git remote add origin https://an...@bitbucket.org/anton/mysubmodule.git
git push --all -u origin

Now, go to superproject and add submodule with options --branch and --depth:
cd ../mysuperproject
git submodule add --branch develop --depth 1 
https://an...@bitbucket.org/anton/mysubmodule.git mysubmodule

Output:
Cloning into 'mysubmodule'...
Password for 'https://an...@bitbucket.org':
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.
fatal: Cannot update paths and switch to branch 'develop' at the same time.
Did you intend to checkout 'origin/develop' which can not be resolved as 
commit?
Unable to checkout submodule 'mysubmodule'

Btw, git version: git version 2.5.0.windows.1

Best regards,
anton

On Wednesday, September 9, 2015 at 2:36:07 PM UTC+7, Anton Akhiar wrote:
>
>
> Hi,
>
> I am trying to add a submodule with option --branch and --depth together, 
> and failed. However, there is no problem if only one of them is applied.
>
> So, this worked:
> git submodule add --branch develop 
> https://an...@bitbucket.org/anton/mysubmodule.git
>
> This is also worked:
> git submodule add --depth 1 
> https://an...@bitbucket.org/anton/mysubmodule.git
>
> But this won't worked:
> git submodule add --branch develop --depth 1 
> https://an...@bitbucket.org/anton/mysubmodule.git
>
> Output:
> Cloning into 'mysubmodule'...
> Password for 'https://an...@bitbucket.org':
> remote: Counting objects: 3, done.
> remote: Total 3 (delta 0), reused 0 (delta 0)
> Unpacking objects: 100% (3/3), done.
> Checking connectivity... done.
> fatal: Cannot update paths and switch to branch 'develop' at the same time.
> Did you intend to checkout 'origin/develop' which can not be resolved as 
> commit?
> Unable to checkout submodule 'mysubmodule'
>
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to