Is there a potential way to clone not complete repository from GitHub, but just selected branches? I've found single branch clone is possible with command:
git clone git@github/path/to/repository.git --branch my_branch_1 --single-branch
So would like to achieve something like this:
git clone git@github/path/to/repository.git --branch my_branch_1 --branch my_branch_2 --single-branch ??
It means only two of them. The issue is, that such repo is quite huge in the master branch and not needed for developers. They just need branches my_branch_1 and my_branch_2. From such branches developers should make their dev branch and later pull request on GitHub to the master.
Maybe it's possible via git remote add or something like this. But I'm not so much familiar probably with the concept of Git internally.
In order to clone a specific branch, you have to execute “git branch” with the “-b” and specify the branch you want to clone. $ git clone -b dev https://github.com/username/project.git Cloning into 'project'...
There are two ways to clone a specific branch. You can either: Clone the repository, fetch all branches, and checkout to a specific branch immediately. Clone the repository and fetch only a single branch.
If you have a single remote repository, then you can omit all arguments. just need to run git fetch , which will retrieve all branches and updates, and after that, run git checkout <branch> which will create a local copy of the branch because all branches are already loaded in your system.
There doesn't seem to a way to clone multiple branches, but you can clone just one, then fetch
the remainder like so:
git clone git@github/path/to/repository.git --branch my_branch_1 --single-branch
git fetch origin my_branch_2:my_branch_2 my_branch_3:my_branch_3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With