Merge

Merge allows you to combine the independent branch developments into a single branch. Git will also try and merge the different branch commit histories together for you.

Let’s now view our Main branch on Gitlab, notice our new file README.md is not there

../_images/mainb.png

Fig 3

We can validate what branch we are on, you should see the asterisk on the dev branch

git branch

* dev
  main

Now using the checkout command, switch back to the main branch

git checkout main
../_images/checkout_m.png

Fig 4

Now we call the branch we want to merge into our current working branch. We will merge dev into main.

git merge dev
../_images/merge_d.png

Fig 5

Remember, this is only a merge locally, you must still push these changes to the remote repository at Gitlab

git push
../_images/push_m.png

Fig 6

Flipping back over to our Gitlab site

../_images/main_gitlab.png

Fig 7

From here we can click on History to view commits that have been made

../_images/main_gitlab_box.png

Fig 8