Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a branch in GitHub

I'm learning Git and experimenting. I understand how to do basic operations but am struggling with creating a new branch. I'm using the command prompt in windows and the github tool in a browser. I have attempted to simulate the creation of a new branch by making a new branch (named branch_1) in the browser, but when I try to find that branch in the command prompt, it does not show up. For example, here's what I get in the command prompt:

git branch
 _notes/dwsync.xml
master
v1.1
v1.2
v1.3

How do I get the new branch to appear?

like image 553
SimonRH Avatar asked Oct 28 '16 15:10

SimonRH


1 Answers

When you create a branch in github, it's in the github remote. You need to fetch the branch from that remote, to your local, and tell your local to track that branch.

git fetch <remote_name> <branch_name>

git checkout --track <remote_name>/<branch_name>

This assumes you want the branch_name on the remote to be the same on your local.

like image 105
Alan Avatar answered Sep 29 '22 08:09

Alan