In SVN I have at least two ways to create a branch:
svn cp /home/me/localcheckout/trunk /home/me/localcheckout/branches/newbranch svn cp http://server/trunk http://server/branches/newbranch
The first creates it locally then I have to commit the whole branch.
The second creates it on the server.
The benefit of the second is that I can svn switch my local trunk, make a few changes to some files and commit just a few KB.
Is it possible to achieve that using Git?
Is there a way of creating a remote branch on GitHub then pull them to my local repo?
The reason that I ask is that I am trying to push a couple of KB to a new remote branch from master using my phones internet connection but when I push it wants to push about 400 MB!
Writing objects: 22% (54080/245586), 86.74 MiB | 13 KiB/s
See Git - pushing a remote branch for a large project is really slow for a similar question.
Adding a remote repository To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at. The git remote add command takes two arguments: A remote name, for example, origin.
It looks like github has a simple UI for creating branches. I opened the branch drop-down and it prompts me to "Find or create a branch ...". Type the name of your new branch, then click the "create" button that appears.
To retrieve your new branch from github, use the standard git fetch
command.
I'm not sure this will help your underlying problem, though, since the underlying data being pushed to the server (the commit objects) is the same no matter what branch it's being pushed to.
Git is supposed to understand what files already exist on the server, unless you somehow made a huge difference to your tree and the new changes need to be sent.
To create a new branch with a copy of your current state
git checkout -b new_branch #< create a new local branch with a copy of your code git push origin new_branch #< pushes to the server
Can you please describe the steps you did to understand what might have made your repository need to send that much to the server.
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