From the course: Use Git Like a Pro by Pearson
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Learn Git branch commands
From the course: Use Git Like a Pro by Pearson
Learn Git branch commands
Let's look at the commands of git branch. So first command we have is to list all the branches, which is git branch. It tells you all the branches you have. Next, we have git branch branch name, which we have already seen in the previous sections. This command creates a new branch. Then we have checkout or switch branch command to switch to an existing branch. You can either use git checkout branch name or you can use git switch to switch to another branch. For creating a new branch and switching to it immediately, you can use git checkout minus p and branch name. In order to delete a branch, you can use git branch-D along with the branch name. Let's practice all these commands. Let's move back to our repo. So right now we are on main branch. We have some changes. I will just remove those changes. I'm using git checkout command. You can also use git restore command to get rid of the changes you have. So now I have no more changes. So first of all, let's use git branch command to see…