Git可以更快地解决合并冲突

时间:2014-10-16 19:36:28

标签: git

我经常遇到合并冲突,如下所示:

$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

我想通过从两个分支进行更改来解决合并问题。我可以手动浏览文件,但这很痛苦。

如何更快地解决这个问题?

2 个答案:

答案 0 :(得分:1)

我强烈推荐xcode mergetool,并经常进行团队rebase。

该工具本身将使你的生活变得更容易,而且这些变化将使你的合并更少成问题。

例如,在我的团队中,我们尽可能频繁地重新集成(我们不会在master中编码)(每周至少两次)。

答案 1 :(得分:0)

最好逐个文件地浏览它;这样你就可以关注你的变化并知道发生了什么。例如,在这3种方式合并

# 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

如果你厌倦了这样做,你可以尝试:

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

我也用Google搜索:http://twobitlabs.com/2011/08/install-diffmerge-git-mac-os-x/ 我不知道你在运行什么,但这应该适用于您所批量的一批文件 试图合并或解决冲突。

当我使用SVN时,我相信tourtoirseSVN有一个差异工具,它对解决大型团队中的多个冲突非常有用。