Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve conflicts on GitLab?

I recently worked with git and there was such a question. I made a merge request from the current branch into master. And received such a message:

enter image description here

What are the options to allow this, so that the button appeared on the site to accept the merge? If I do local merge then it closes automatically, but I don’t need to. Are there any options?

like image 916
Mefisto_Fell Avatar asked Oct 19 '18 16:10

Mefisto_Fell


1 Answers

Normally to resolve issues like this I would do the following locally:

git pull origin master

This should pull the current master from the remote and merge it with your local branch, then you can resolve the conflicts on your local copy, commit that and you should be good to proceed with your merge

I have since been told that the better way to do this is to rebase, by taking all the changes on your local branch since the most recent common commit on the master, you can apply those changes to the current master, when you're on your local branch you can run:

git rebase master

This will delete your commit and create a new commit with all the changes and you don't need a second commit. This means the git history will be cleaner.

To try to avoid this when going forward, try to make sure you pull master before making a new branch so you're up to date when you start. Obviously if you take a while to ready your commit before trying to merge again you might need to pull the master in again to make sure you don't have a conflict first.

like image 175
Rumbles Avatar answered Oct 09 '22 16:10

Rumbles