# Merging branches with Git

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1678897535928/bc5b41c9-8581-453a-92ce-a799caa6aab4.png?auto=compress,format&format=webp align="center")

[`🇻🇪 Spanish`](https://crisprogramando.hashnode.dev/fusionar-ramas-con-git)

1.- I am going to show you the merge between branches. First, create the `update-person-class` branch from the `stable` branch. Visit: [Creating branches with Git.](https://crisprogramming.hashnode.dev/creating-branches-with-git)

2.- See all branches with `git branch` command.

```javascript
git branch
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1678897590400/6f865fdc-391f-47c3-a1c8-9e52a884b7ec.png?auto=compress,format&format=webp align="center")

3.- Enter inside the `stable` branch with `git checkout <branch_name_to_receive_merge>` command, because I am going to merge the `update-person-class` branch inside the `stable` branch.

```javascript
git checkout stable
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1678897638336/0d8c76a1-6ae2-4dd3-87de-41761e12d0cb.png?auto=compress,format&format=webp align="left")

4.- In this example, the file `30class` is different in every branch.

***File*** `30class` ***in*** `stable` ***branch:***

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1678897848661/a66a5f5b-d1f3-4167-b3a0-139e749ed03f.png?auto=compress,format&format=webp align="left")

***File*** `30class` ***in*** `update-person-class` ***branch:***

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1678897887512/4f87b3c8-a175-4051-8f78-df514fd21013.png?auto=compress,format&format=webp align="left")

5.- Merge branches with `git merge <new_branch>` command. In this example, I am going to merge the `update-person-class` branch inside the `stable` branch.

```javascript
git merge update-person-class
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1678897962302/d50f2b0e-8236-4a42-9141-ce232c8e0751.png?auto=compress,format&format=webp align="left")

6.- Push changes with `git push origin main` command from the local repository to the remote repository.

```javascript
git push origin stable
```

7.- The file is updated in the `stable` branch.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1678898044999/a3659e1a-6040-4ddf-bd6b-afb9ddb55c7b.png?auto=compress,format&format=webp align="left")

8.- Delete the deprecated branch with `git branch -d <new_branch>` command.

```javascript
git branch -d update-person-class
```

9.- If there are conflicts between the branches, you can solve them in Visual Studio Code.

10.- You can continue with `git merge --continue` command after you fix the conflicts.

```javascript
git merge --continue
```

### **Reference:**

[**git-scm.com/book/es/v2**](http://git-scm.com/book/es/v2)
