Eclipse adds tag to code when trying to resolve conflicts

Asked

Viewed 214 times

-1

Guys, the following situation serves only to exemplify what happens when I try to resolve a conflict over the Eclipse. I know how to resolve a conflict, the problem is that after solving it these tags remain present. Conflicts will always exist, I have no way of avoiding them in my project, and they are there to be resolved, and I know how to solve them. Well, follow the steps I follow:

By merging through Eclipse, from the master to the branch I’m working on, I come across a conflict.

  1. I do a Synchronize
  2. I select the conflicted file
  3. Right click, Merge Tool
  4. I do not change anything (Although sometimes I change and gives the same thing)
  5. Right click on the file again
  6. Add to index.

When I open the file I check that Eclipse saved it with this image tags below.

tag que inviabilizam o codigo

The strange thing is that Merge Tool offers the option of 3 editors when it shows the comparison. If I select Text Editor the conflict is solved without this problem, if I leave the default (default) problem happens.

inserir a descrição da imagem aqui

  • It’s not the Eclipse that does it, it’s the Eclipse itself git (Eclipse menus only call git commands). Anyway, I think it’s interesting to know because conflicts arise, read https://www.atlassian.com/git/tutorials/using-branches/merge-conflicts - knowing why they arise, it is easier to avoid (it is not always possible, of course, but at least you know why it happened). From the image you put it’s kind of hard to know, but think which is why these lines should have some whitespace or tabs on a branch and not in master (or vice versa), or something like...

  • These are difficult conflicts to avoid, there are many people working on the same thing, but I know how to solve it well, the problem is precisely these tags that are added. And I think it’s the eclipse because if there in the compare view I use the text editor instead of the default, it saves normally without problem. But it’s one more job I’d like to avoid.

  • It’s not eclipse, if you run git on the command line and you have conflict, it also adds these markups. Maybe the problem is another (someone has an auto-format config in the eclipse that removes spaces from empty lines and ends up creating conflict, for example - I don’t know, it’s what came to mind, it can be so many things, and only with the information of the question is difficult to guess). Anyway, if there’s too many people doing the same thing, there is another problem, and it is not git that will solve... :-)

  • if it is not the eclipse, why is it that by using a different editor in compare viw, the conflict is solved smoothly?

  • What I meant is that if there is a conflict, it’s git that adds these markups (it puts the characters >>> in the archive). Now, if the conflict only occurs when you use the Eclipse, then that’s another story, and as I said, just with the information of the question, it’s hard to guess (have to see what each one is doing, it may be the auto-format issue I mentioned earlier, or some other detail that escapes me now...)

  • I edited the question a little bit, what additional information do you need? vc uses the eclipse?

  • I use Eclipse sometimes, but when I use git, I always go on the command line, so I never had this problem that you reported. Sorry I can’t be of more help...

Show 2 more comments

1 answer

0

has to study the flow of git. The conflict happens because the q vc branch is trying to merge this one or more commits behind the one you’re working on. follows a mini tutorial on how to resolve conflicts:

Merge the master branch with the style Let’s go back to the style branch and merge it with a new master.

EXECUTE:

git checkout style
git merge master

RESULT:

$ git checkout style
Switched to branch 'style'
$ git merge master
Auto-merging lib/hello.html
CONFLICT (content): Merge conflict in lib/hello.html
Automatic merge failed; fix conflicts and then commit the result.

If you open lib/hello.html you will see:

ARQUIVO: LIB/HELLO.HTML
<!-- Author: Alexander Shvets ([email protected]) -->
<html>
  <head>
<<<<<<< HEAD
    <link type="text/css" rel="stylesheet" media="all" href="style.css" />
=======
    <!-- no style -->
>>>>>>> master
  </head>
  <body>
    <h1>Hello,World! Life is great!</h1>
  </body>
</html>

The first section and the version of the current branch (style) head. The second section is the version of the master branch.

02Resolution of the conflict You need to resolve the conflict manually. Make changes to lib/hello.html to achieve the following result.

FILE: LIB/HELLO.HTML

<!-- Author: Alexander Shvets ([email protected]) -->
<html>
  <head>
    <link type="text/css" rel="stylesheet" media="all" href="style.css" />
  </head>
  <body>
    <h1>Hello, World! Life is great!</h1>
  </body>
</html>

03Shoot a conflict resolution commit EXECUTE:

git add lib/hello.html
git commit -m "Merged master fixed conflict."

RESULT:

$ git add lib/hello.html
$ git commit -m "Merged master fixed conflict."
Recorded resolution for 'lib/hello.html'.
[style 645c4e6] Merged master fixed conflict.

If you want to learn more about git how to read the following link

https://githowto.com/

  • Friend, I appreciate the answer, but I wish I could solve it by the eclipse tool itself and not by the command line. The problem is not how to resolve conflicts, but why by solving them using the eclipse merge tool, these tags remain present.

  • the tags will always appear when there is conflict. This is a git protection to prevent vc from losing Cod or implementing broken things in your update or even to avoid problems when 2 people move the same block of code.

  • conflicts are frequent. I believe that when you need to perform a task the first thing you do is pull a branch from the master project. then executes the task. Test it and if ok merge with the master and finish the task branch.

  • yes, we always solve, I even gave an edited question, the problem is that when using the eclipse I come across this problem, when I solve in other ways goes smoothly

  • sometimes you’re doing it wrong. I’m sorry I can’t help with the eclipse because in git I work all in-line command.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.