Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Fetch a specific branch using git

I tried this:
#git clone git://github.com/Xilinx/u-boot-xlnx/tree/master-next.git

Initialized empty Git repository in /home/Hannan/master-next/.git/
fatal: remote error:
Xilinx/u-boot-xlnx/tree/master-next is not a valid repository name
Email support@github.com for help


Even this failed:
# git clone git://github.com/Xilinx/tree/master-next/u-boot-xlnx.git
Initialized empty Git repository in /home/Hannan/u-boot-xlnx/.git/
fatal: remote error:
Xilinx/tree/master-next/u-boot-xlnx is not a valid repository name
Email support@github.com for help


The command that works is:
git clone git://github.com/Xilinx/u-boot-xlnx.git

But how do I know that this will indeed fetch the master-next branch and not the master branch? How do I correctly fetch a specific branch using git?

I am using RHEL 6, accessed via PuTTY.
by

1 Answer

Amit8z4mc
This command should work:
$ git fetch origin [branch]


The above command only fetches metadata from remote repository, it not does merge sources.

If you want to fetch and merge the sources, the command would be:
$ git pull origin [branch]


Be careful with the branch where you are executing merge command. It will be where the sources are merged.

Login / Signup to Answer the Question.