Hello people! This is going to be a very quick post. For this post I am going to assume that you have some familiarity with GitHub. I am going to discuss the steps required to create a branch when you are logged on to github and how you could clone this branch to create a local working copy.
Let me take an example. Assume you have a repository called
ruby-practice with only a
master branch. Now, in order to create a new branch, follow the following steps:
- Below the
Clone in Windowsbutton in your repository, you will see a
branchdropdown that has
- Now click on the down arrow and in the text box you see enter the name of the new branch
- Once you are done entering the new branch name, wait for a few seconds, you will see the
Create branch: <your_branch_name>button appear [blue highlighted block]
- Let us assume you entered
- Click on this button, the branch will be created and you will be redirected to this new branch
Given below is a screenshot that shows this particular section:
If you don’t get the create branch button even after waiting for a few seconds, press the space bar, you will see it now. Now remove the space added and now click the create branch button.
Now that you have created the branch, lets see how a local copy could be created in order to work on this independently apart from the master branch. I am going to use the shell to do this, since I am much more familiar with the shell than the UI.
Open the github’s shell, and
cd to the folder where you would like to create the working directory for your branch. Let us assume the base folder is
C:\users\karthik\GitHub. First step is to create the folder which will contain your branch
Now enter the following command to clone the branch to your local working directory:
git clone email@example.com:karthik25/ruby-practice.git -b ruby-practice-v1.0 .\ruby-practice-v1.0
At this point, the branch is cloned and is ready for use! Just
cd to the new directory to get started
Hope you enjoyed this short post! Have fun with github! And as always happy coding!