5
set -e
cd /source

git clone --depth 1 https://github.com/named-data/ndn-cxx.git

pushd ./ndn-cxx

git checkout -b release-build ndn-cxx-0.3.3

./waf configure

./waf

./waf install

popd

rm -rf ./ndn-cxx

I am running the above mentioned script, but getting the error: "Cloning into 'ndn-cxx'... /source/ndn-cxx /source fatal: Cannot update paths and switch to branch 'release-build' at the same time. Did you intend to checkout 'ndn-cxx' which can not be resolved as commit?"

edi9999
  • 19,701
  • 13
  • 88
  • 127
user3240356
  • 115
  • 1
  • 5
  • possible duplicate of [Git checkout on a remote branch does not work](http://stackoverflow.com/questions/945654/git-checkout-on-a-remote-branch-does-not-work) – Tim Biegeleisen Jul 13 '15 at 08:24

2 Answers2

7

By default, if you specify the --depth option, git will only fetch the master branch, so you won't be able to checkout to any other branch.

You can write the following :

git clone --depth 1 <url> --single-branch --branch <branch>

to retrieve the latest version of <branch> instead, like this:

git clone --depth 1 https://github.com/named-data/ndn-cxx.git --single-branch --branch ndn-cxx-0.3.3

You won't have to do a git checkout after the clone

edi9999
  • 19,701
  • 13
  • 88
  • 127
0

As @edi9999 said above, --depth option fetches a single branch by default. If you want to fetch all other branches near the tip of the specified depth, you have to specify --no-single-branch option.

E.g.

git clone https://github.com/named-data/ndn-cxx.git --depth 1 --no-single-branch
elquimista
  • 2,181
  • 2
  • 23
  • 32