"git sourcetree Conflict" solution

Source: Internet
Author: User
Tags diff svn sourcetree

Original address: https://segmentfault.com/a/1190000002951154

Now the program ape Standard Git as a code management, but from the SVN to Git learning, where git conflict is a difficult point, often lead to push does not go up, pull down, very awkward, still do not know that their code is overwritten no, nonsense not much to say, directly on the dry. Highlights

construct conflicts using Sourcetree plug-ins and beyondcompare visual conflict resolution methods

A modifies the 1th line in Conflict.file and commits to Git

B at this time also modified the confilct.file in the first line of content ready to submit, this time git will prompt

To Git@192.168.x.xxx:xxx/server-aggregator.git
 ! [Rejected]        Develop-Develop (fetch first)
error:failed to push some refs to ' git@192.168.xx.xx:xxx/server-aggregator.git ' C3/>hint:updates were rejected because the remote contains work, that you do
Hint:not has locally. This was usually caused by another repository pushing hint:to the
same ref. Want to first integrate the remote changes
hint: (e.g., ' git pull ... ') before pushing again.
Hint:see the ' Note about Fast-forwards ' "Git push--help ' for details.

Hint that the remote has been updated, the local version is too low, let's pull up the latest code first.

We pull, this time due to local modification of this file, it will generate a local conflict file

Configuring the External comparison tool

Download Beyond Compare

Open sourcetree-> Tools, options, comparison, external differences compare merge, select Beyondcompare Resolve Conflicts

Open External Merge tool in resolve conflicts, local copy, right-click

Resolve conflicts as well as SVN save changes and exit

another situation

The following prompt appears when pulling:

It-c diff.mnemonicprefix=false-c Core.quotepath=false Pull local-server-aggregator Develop
/opt/gitlab/embedded /service/gitlab-shell/bin/gitlab-shell:3: Warning:insecure World writable DIR/USR in PATH, mode 040777 from
192.168 .0.200:weitoo/server-aggregator
 * Branch            Develop-    fetch_head
Updating b0c5c94. 40CEF3B
Error:your Local changes to the following files would is overwritten by merge:
    server/conflict.file
P Lease, commit your changes or stash them before you can merge.
Aborting

Prompt to stage local modifications to pull new code on the server

Click Storage (English version: Stash), any name, which is stored in the distance from the last server version to local changes between the differences, do not delete, the merger succeeded and then deleted.

Pull pulls the server code, and at this point the local code becomes the code on the server.

Click on the store-and-apply storage area, this time is to merge the previous changes to the local, this time will prompt the conflict.

Git-c diff.mnemonicprefix=false-c core.quotepath=false stash apply stash@{0}
auto-merging Server/conflict.file
CONFLICT (content): Merge CONFLICT in Server/conflict.file

You can see an exclamation point in the Sourcetree, representing the conflicting file, similar to the above conflict resolution method, but slightly different, the leftmost version is remote, the middle is the remote version, and the last is the local modification.
This is related to the way we operate: we first staged local changes, first pull remote code, this time the local becomes the remote code, and finally we use the temporary merge into, remote is a local modification

redundant. orig Files

This is because git itself causes it to resolve the conflict and generate a backup of the original conflict, we can remove

git config--global mergetool.keepbackup false


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.