From My Dev Notes- Git Basics: Cloning and Branching
Today, in this series of making a note of my daily understandings as a developer, I’ll be sharing some basic understandings of git.
Let’s say you’re working on a live project, like we do in corporate. The very first thing you’ll need to do is to set things up in your local. Setting up the required IDEs and pre requisites.
The next step includes cloning your project locally. How to do that?
Well, it's simple (and fun!!). Just running a few through the terminal and all done!
Cloning the Repo
To clone the repo locally into your machine, you first need to go to the github repository. There you’ll see a green Code button, you’ve to click the dropdown and copy the https link there.
Then you’ll have to go to your terminal, either your command prompt or IDE’s terminal. Navigate to the file location you want to save this repo locally and use this command:
git clone <your_copied_url>Enter and your repo will be cloned to the specified location.
Dealing with Branches
If you want to add a new feature to an ongoing project, its conventional to do that in a new branch so that it doesn’t affect your existing codebase.
Get Shikha Sinha’s stories in your inbox
Join Medium for free to get updates from this writer.
To create a new branch, use this command:
git branch <branch-name>If you want to create and switch to the new branch immediately, use:
git checkout -b <branch-name>Or, using the newer syntax:
git switch -c <branch-name>In case you want to check your current Git branch, use the following command:
git branch --show-currentAlternatively, you can list all branches with the following command and the branch which will be marked with an asterisk(*) would be your current branch:
git branchI’ll continue publishing my daily understandings of the dev world. More insights coming soon!!




