简体   繁体   中英

Git resolve merge conflict faster

I often have a merge conflict that looks like this:

$lang['config_default_sales_person'] = 'Default sales person';
$lang['config_require_customer_for_sale'] = 'Require customer for sale';
$lang['config_commission_default_rate'] = 'Commission Default Rate';
$lang['config_hide_store_account_payments_from_report_totals'] = 'Hide store account payments from report totals';
<<<<<<< HEAD
$lang['config_test_3'] = 'test 3';
=======
$lang['config_test'] = 'test';
>>>>>>> test2

I want to resolve the merge by taking taking changes from both branches. I can manually go though the files but it is a pain.

How can I resolve this faster?

I'd highly recommend xcode mergetool, and doing frequent team rebases.

The tool itself will make your life 100x easier, and the rebases will make your merges less problematic.

For instance on my team we rebase integration (we don't code in master) as often as possible (at least twice a week).

It's better to go through it file by file; this way you can eye your change and know what happened. For example, in this 3 way merge

# Start a new feature
git checkout -b new-feature master

# Edit some files
git add <file>
git commit -m "Start a feature"

# Edit some files
git add <file>
git commit -m "Finish a feature"

# Develop the master branch
git checkout master

# Edit some files
git add <file>
git commit -m "Make some changes to master"

# Merge in the new-feature branch
git merge new-feature
git branch -d new-feature

If you get tired of doing it, you can try:

http://www.gitguys.com/topics/merging-with-a-gui/

I also googled: http://twobitlabs.com/2011/08/install-diffmerge-git-mac-os-x/ i'm not sure what you're running but this should work on batch of files that you're trying to merge or resolve conflict.

When I was using SVN I believe in tourtoirseSVN there was a diff tool which was really useful in resolving multiple conflicts in large teams.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM