Create a remote branch on GitHub

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.


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.

create branch github ui

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.


Before creating a new branch always the best practice is to have the latest of repo in your local machine. Follow these steps for error free branch creation.

 1. $ git branch (check which branches exist and which one is currently active (prefixed with *). This helps you avoid creating duplicate/confusing branch name)
 2. $ git branch <new_branch> (creates new branch)
 3. $ git checkout new_branch
 4. $ git add . (After making changes in the current branch)
 5. $ git commit -m "type commit msg here"
 6. $ git checkout master (switch to master branch so that merging with new_branch can be done)
 7. $ git merge new_branch (starts merging)
 8. $ git push origin master (push to the remote server)

I referred this blog and I found it to be a cleaner approach.