Intellij解决版本冲突--Resolving Conflicts

10 篇文章 0 订阅
9 篇文章 0 订阅

Depending on the type of your version control system, conflicts arise in different situations.

Non-Distributed Version Control Systems

Working in a team, you might come across a situation, when somebody commits changes to a file you are currently working on. Conflicts can also arise on merging branches, applying patches or unshelving changes. If the changes are not overlapping, the files are merged automatically, but when there are changes to the same lines, you will need to resolve such conflict yourself.

When you try to edit a file that has a newer version on the server, IntelliJ IDEA informs you about that, showing a message pop-up window in the editor:

img
In this case you should update your local version prior to changing the file, or merge changes.
If you try to commit a file that has a newer repository version, an error is reported in the Messages tool window:

img
Depending on the behavior chosen from the Create changelist on failed commit drop-down list in the Confirmation page of the Settings dialog box, IntelliJ IDEA does one of the following:
Creates a Failed Commit changelist, moves the conflicting files to it automatically, and highlights the names of the files red. This behavior takes place if the Yes option is chosen.
img
Leaves the conflicting files in the changelist where they were but highlights them red. This behavior takes place if the No option is chosen.
Displays a dialog box, where you can choose to move the conflicting files to a new changelist or leave them in the original one. In either case, the conflicting files will be highlighted red. This behavior takes place if the Ask option is chosen in the Confirmation page.
If you synchronize a file, that already has local changes, with a newer repository version, committed by somebody else, a conflict occurs. The conflicting file gets status Merged with conflicts. The file remains in the same changelist in the Local tab of the Changes tool window but its name is highlighted red. If the file is currently opened in the editor, the file name on the tab header is also highlighted red.

Distributed Version Control Systems

Under Git, conflicts arise during merge, rebase, cherry-pick, unstash, or apply patch.

Conflict Resolution Tool

IntelliJ IDEA suggests a tool for resolving conflicts locally. This tool consists of three panes. The left pane shows the read-only local copy; the right pane shows the read-only version checked in to the repository. The central pane shows a fully-functional editor with the results of merging and conflict resolving. Initially, the contents of this pane is the same as the base revision of the file, that is, the revision from which both conflicting versions derived.

img
To resolve conflicts, follow these general steps

Select the conflicting file in the Changes, Update Version Control, or Project tool window, or open it in the editor.
On the context menu, under the node of your VCS integration, choose the VCS-specific merge command.
Perform edit in the merge tool to apply or discard changes, as described in the procedures below.
To apply or discard a change

In the left or right pane, select the change to be merged. Use arrow and/or find buttons on the toolbar to navigate to the desired location.
Accept or reject changes, clicking the chevron or X button respectively.
Click Apply.
To apply all non-conflicting changes

On the toolbar of the merge tool, click iconMergeNonConflicting.png. It is useful to automatically accept any changes that are not in conflict, and spend your time working on conflicting changes.

原文链接

这里写图片描述

这里写图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值