Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a branch without cloning?

Tags:

git

git-branch

I'd like to automate the creation of feature branches that match in multiple projects. I can script this but to speed things up it would be nice if I could just tell the remote repo to create the branch, without cloning the entire source code. Is this possible?

like image 475
Marty Avatar asked Oct 02 '22 13:10

Marty


1 Answers

If your remote repo isn't bare, then you can do all this using ssh and running the git commands directly on your remote repository. The syntax for ssh is pretty simple: ssh user@host command:

ssh dev1@remotebox git branch newbranchname
ssh dev2@remotebox git checkout newbranchname
ssh jenkinsci@remotebox git pull --quiet --no-commit

And so on.

If your remote repo is bare or if you cannot ssh to the remote repository, then no, you can't do this. The git transfer protocol doesn't permit it. As far as I know, the only commands you can run on remote repositories without a local clone all have the "-remote" suffix. ls-remote, peek-remote and parse-remote.

like image 114
Paul Hicks Avatar answered Oct 13 '22 10:10

Paul Hicks