Beyond Compare as a Diff and Merge tool with Git
2012-11-20 13:10
399 查看
Beyond Compare is an excellent file comparison utility and can be configured with Git as a merge and diff tool.
To setup diff on Linux, create a short wrapper script to pass the parameters in the correct order:
vi ~/git-diff-wrapper
?
git config --global diff.tool bc3 git config --global difftool.bc3.path "C:\Program Files (x86)\Beyond Compare 3\BComp.exe"
Now edit your git config using the sample below to configure merging and use of the script above:
Linux
vi ~/.gitconfig
?
Windows
notepad C:\Program Files\git\etc\config
?
diffmerge for a similar solution. Here's a sample configuration:
OSX w/ diffmerge
vi ~/.gitconfig
?
LOCAL – Current branch version
REMOTE – Version to be merged
BASE – Common ancestor
MERGED – File where results will be written
Now you can use Beyond Compare for diff (git diff) and to handle conflicts.
The sequence of commands for a merge using mergetool would be:
git merge
git mergetool -t [tool]
git add .
git commit
For example:
Pull changes on a file that has been modified by another user:
git fetch origin git pull origin master From github.com:domain/project * branch master -> FETCH_HEAD Updating c44e43e..b3813c5 error: Entry 'filename.php' not uptodate. Cannot merge.
Attempt to update your changes with automatic merging:
git add filename.php git commit -m "made x changes" From github.com:domain/project * branch master -> FETCH_HEAD Auto-merging filename.php CONFLICT (content): Merge conflict in filename.php Automatic merge failed; fix conflicts and then commit the result.
Now merge using Beyond Compare:
git mergetool
If you complete the merge and save it, mergetool will accept the result. If not, you can accept changes, or use another version wholesale:
git checkout --ours filename.php git checkout --theirs filename.php
Commit the changes:
git add filename.php git commit -m "made x changes"
Verify:
git pull origin master From github.com:domain/project * branch master -> FETCH_HEAD Already up-to-date.
git mergetool also includes preconfigured support for a number of open source merge tools: kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff. These can be used with the -t flag:
git mergetool -t kdiff3
相关文章推荐
- How to Use Kdiff3 as a 3-way Merge Tool With Mercurial, Git, and Tower.app
- How to Use Kdiff3 as a 3-way Merge Tool With Mercurial, Git, and Tower.app
- Use vimdiff as git mergetool
- Linux using Beyon compare4 as Git diff tool
- git difftool bcompare
- meld--Visual diff and merge tool for the GNOME Desktop
- Howto use vimdiff as "git diff"'s diff tool
- git gui diff/merge tool
- git diffmerge tool 配置
- [Practical Git] Compare file changes with git diff
- Learning Source Control with Git and SourceTree.pdf
- install opencv 3.0.0 with python 3.4 on Mac using Homebrew and Git
- 搞定Git中文乱码、用TortoiseMerge实现Diff/Merge
- How to create and apply a patch with Git
- IBM Rational Synergy 与 SimDiff 的集成,解决“.dml ”文件compare,merge 问题
- git集成Beyond Compare,方便 diff 和 merge
- Version Control with Repo and Git
- [Angular 2] Handling Clicks and Intervals Together with Merge
- <merge /> can be used only with a valid ViewGroup root and attachToRoot=true
- TextView with SingleLine as true and Gravity as Center not passing the events to the ViewPager if it has a Click Event