Is it possible to make a branch in a remote master repository without having a local clone of the repository?
The repository is large enough that cloning a copy just to make and push the branch is extremely wasteful (about 20 minutes), especially as the branch is being made by an automated system for procedural and functional reasons, and it will not need the contents of the repository itself.
Not based on existing branches but you can push in an empty branch using a completely new unrelated repository. Try out the following test instructions
Creating the original repo for the test
cd ~/Desktop/test mkdir original_repo && cd original_repo git init && touch testfile && git add . && git commit -m "master repo" cd ..
Create a new empty repo
mkdir hacky_repo && cd hacky_repo git init && touch init && git add . && git commit -m "empty new repo"
Add the original repo as a remote to this repo
git remote add original ../original_repo/
And now push the branch from this repo to the orignal repo
git push original master:some_new_branch cd ../original_repo
If now you do a
git branch - you should have the new branch there in your original repo.
$) git branch * master some_new_branch
The assumption here is that you know in advance which all branches / branch namespace are free.
In addition of pushing a branch from any repo, other possibilities include setup on the server some kind of listener in order to:
But that supposes you have access to that server.
If the server is GitHub, you wouldn't be able to do that, but you would have the GitHub API to work with, like "Create a reference".
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