From the course: Learning Software Version Control

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Git branching and merging

Git branching and merging

- [Instructor] In Git, we can use branching to create a new line of development separate from the main branch. Let's see how it works. Here I have a JavaScript class and I want to include a new feature. So I'm going to create a new branch with git branch, and let's called it newFeature. Now, I need to switch to the new branch with Ggit checkout and the name of the branch, newFeature. Hit Enter. I can include changes here, which only affect the main project once merged. For example, here I want to include a new method inside this class and a branch work exactly as the main trunk. We can save or revert changes. So to commit changes in this branch, let's type git add and git commit -m with a message, which is new feature. Now, this feature is only present on my new branch. Let's start merging the code. In case you need to know the name of your branches, you can type git branch -a. And as you can see, we have two…

Contents