# Branching and merge conflicts

Working in feature branches is another common scenario. It's rare to code directly against master. Usually developers will create a branch, make their changes, and then merge the branch back into master.

{% tabs %}
{% tab title="Exercise" %}

* Create a new branch called "description\_fix"
* Modify the description in the "index.html" file
* Switch back to the master branch
* Change the description meta tags in the "index.html" file
* Merge in the "description\_fix" branch
* Resolve merge conflicts with VS Code
* Push changes to Github
  {% endtab %}

{% tab title="Answer" %}

* Click the "master" branch label in the status bar

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7RAgOyvXSv5mshI0u%2F-Lm7RScLwrjnWJ_p5k0w%2Fimage.png?alt=media\&token=3f5feb56-a269-42ea-be32-dead9c2e2b21)

* Select "Create new branch"

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7RAgOyvXSv5mshI0u%2F-Lm7R_V6L4SNz_94FieI%2Fimage.png?alt=media\&token=84c686c5-8913-4170-a7e9-b4934bd23704)

* Enter "description\_fix" as the branch name

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7RAgOyvXSv5mshI0u%2F-Lm7ReDIU7upNJ2M0UBb%2Fimage.png?alt=media\&token=3c3982ae-8947-4fcd-bc22-79067fcb97d7)

* Change the content of the "description" meta tags to be "I ate a big red candle. I love lamp"

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7RAgOyvXSv5mshI0u%2F-Lm7S27U-QaCijLPHH9Y%2Fimage.png?alt=media\&token=d3b05b22-4b05-44e9-b858-bf67a12658f7)

* Stage and commit the changes to the branch as in the previous exercise
* Click on the "description\_fix" label in the status bar
* Switch back to the master branch

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7RAgOyvXSv5mshI0u%2F-Lm7SEDaMXW2PV9MmOcm%2Fimage.png?alt=media\&token=e1c69130-d737-42ef-ae07-210633679392)

* Modify the "description" metatags to be "I enjoy lamp"

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7SK0S2D-fqkVNq79B%2F-Lm7SY1wFvWXG2YUipYn%2Fimage.png?alt=media\&token=72bb0143-acab-4522-8ff4-befe8c4e603e)

* Stage and commit the changes to the master branch
* Open the Command Palette (**Cmd/Ctrl + Shift + P**)
* Select "Git: Merge Branch"

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7SK0S2D-fqkVNq79B%2F-Lm7SmcP3h-NfIeRVDFH%2Fimage.png?alt=media\&token=480817ed-819a-4426-9124-cd165246e8c2)

* Select the "description\_fix" branch
* VS Code will immediately warn that there are merge conflicts

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7SK0S2D-fqkVNq79B%2F-Lm7TPb4ld_XrhJoAzfb%2Fimage.png?alt=media\&token=c85a34c9-3857-4192-89b6-e5bb01ce4021)

* Select "Accept incoming change"

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7SK0S2D-fqkVNq79B%2F-Lm7TWDpR2Eafy0kTnbX%2Fimage.png?alt=media\&token=5bdba3b8-7383-4e58-aa80-9743dadd2375)

* Open the Command Palette (**Cmd/Ctrl + Shift + P**)
* Select "Git: Delete Branch"
* Delete the "description\_fix" branch

![](https://1151923643-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LlvtEHKkq5bvzPq1pJ4%2F-Lm7SK0S2D-fqkVNq79B%2F-Lm7TjJ3uznOdlzPnH-4%2Fimage.png?alt=media\&token=7ba6bba3-d9e0-4a7a-9baf-e738554c76d4)

{% endtab %}
{% endtabs %}
