I am trying to pull from a repository in Github. But I don\'t want to clone the master branch. I want to clone some other branch. When I try git clone
,
use git clone --branch <name>
possibly adding --single-branch
as usual you have git clone --help
to read details on commands
Try this:
git init
git fetch url-to-repo branchname:refs/remotes/origin/branchname
EDIT
A better solution:
git clone -b mybranch --single-branch git://sub.domain.com/repo.git
git clone <url>
clones and creates remote-tracking branches for each branch. If you want to see available branches (after cloning), you type
git branch -l
To switch to a particular branch after cloning you do:
git checkout <branchname>
where branchname is the name of the branch :)
If you want to clone and checkout a specific branch you do
git clone -b <branchname> <url>
The other commands you mention are for "updating" your current working copy. git pull
gets all changes from the remote repository and merges them while git fetch
only gets them without merging.
If you already cloned the repo and want to contribute to the branch other than master, do this:
$ git checkout --track origin/<branch-name>
Of course, be sure to specify the right name of the remote (origin in the example above)
This command will create a new local branch that will track a particular remote branch.