V
V
Vadim2020-06-18 12:39:56
git
Vadim, 2020-06-18 12:39:56

What happens under the hood of git when resolving a Merge conflict?

Hello everyone,

a typical situation is before sending branch feature-A234 to a remote repo with (git push origin feature-A234) I do a local merge like this:
git checkout develop
git pull develop
git checkout feature-A234
git merge develop
---> I get next merge conflict (on the picture)
5eeb2982df4f2182930905.png

Editing the file shown on the screen, deleting
>>>>HEAD
>>>>develop

It turned out in general, a mixture of develop and my branch :

24: resource "aws_network_acl" "feature_acl" {
25: ## this acl created by the other user
26: vpc_id = "${aws_vpc.main.id}"
27: }
28:
29: resource "aws_network_acl" "my_acl"{
30: ## this acl created by vadim
31: vpc_id = "${aws_vpc.main.id}"
32: }

then do
git add -A
git commit -m "conflict resolution"
git push origin feature-A234

Then do Pull Request on a remote GitHub/Bitbucket and there are no conflicts... I don't understand why, because I changed everything and even added new lines like vpc_id = "${aws_vpc.main.id}" ? After all, the original develop does not have this code and Pull Request should create a new conflict due to line overlap, but it does not happen.

Can you explain in more detail how this works?

all the best,
Vadim

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
Xitsa, 2021-11-30
@Viji

A conflict would arise if the file in the original develop was modified.
And so, git sees that there is a commit path to the file in the original develop and it corresponds to the one on which the changes were applied during the conflict resolution, which means that you can safely replace the file with a new one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question