5

I have a need, via automation, to create a new branch on the git remote, but I need to do this without the overhead of first getting a local copy of potentially large repos.

Unless I'm missing something (obvious or subtle), every example I find presumes I want to 'fetch', 'clone' or 'checkout' the repo locally, then make a branch, then push to the origin.

This isn't what I want to do. I need, from a script that's running on a ubuntu server where I cannot afford the overhead of cloning repos, to simply add a branch to the remote, so others can then pull down that branch and start working.

The use case is, I'm working with an automation framework where we are enforcing best practices by creating feature branches before developers begin working.

Using GitHub or GitLab this is easy via the API. In some cases where my customers are simply using 'git', I have to do this using the command line and scripting.

I know this may be ambiguous, so please let me know if the question isn't clear.

4
  • 1
    According to stackoverflow.com/questions/14930383/… it doesn't seem possible. However you can add a --depth=1 to the clone command plus tell it to only fetch the branch you want to stand on when pushing your new branch to get minimal history downloaded. Commented Feb 23, 2016 at 14:46
  • Is it possible to ssh into where the remote is and from there execute the git branch command? Commented Feb 23, 2016 at 16:07
  • @AdamParkin - I wish but no, the remote is on a server I cannot access via ssh due to "security concerns". Commented Feb 23, 2016 at 16:31
  • There's something very weird about this arrangement. If they won't give you access to a repo you refuse to clone, why do you think they want you arbitrarily adding branches? Remote administration can be done via receive hooks. Commented Feb 23, 2016 at 20:48

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.