From the course: Learning Git and GitHub

Unlock this course with a free trial

Join today to access over 23,100 courses taught by industry experts.

Branches

Branches

- [Instructor] One of the most powerful features of Git is the ability to create branches. Now, branches let you create different versions of your code, so that you can play around with adding new features without worrying about messing up what's stable. The simplest command you can use is called branch. It lets you take a look at all the branches in your repository. Right now, we only have a single branch. So if we take a look at our project, and we do Git branch, you'll see that we have a single branch called main. Typically, what you want to do is make a copy of an existing branch. You can do that with the Git switch command. It will have the same history as the current branch. There's a slightly older version of this command called Git checkout, and you may see that in a lot of examples. Notice that with Git checkout, you have to do Git checkout -b, and then the name of the new branch that you want to create,…

Contents