1 Set up vimdiff

The vimdiff as a merge tool will display several buffers to show the yours/theirs/original changes.

The key point is to set up the vimdiff so that the buffer number in the vimdiff status line is visible.

First, add following code into your ~/.vimrc

set laststatus= "show the status line
set statusline=%-.3n "buffer number

Second, if you know the buffer number, you can use hot key like ",2" (press comma first, then press two as quickly as possible) to pull change from buffer number two.Add below code into your ~/.vimrc to set up hot keys:

map <silent> <leader> :diffget <CR> :diffupdate<CR>
map <silent> <leader> :diffget <CR> :diffupdate<CR>
map <silent> <leader> :diffget <CR> :diffupdate<CR>
map <silent> <leader> :diffget <CR> :diffupdate<CR>

注意: 设置hot key的时候,需要将<leader>替换为你需要设置的前导符号,例如如果设置 ",2" 为获取buffer 2 的内容,那么你需要将 <leader>设置为 ','

即:

map <silent> , :diffget <CR> :diffupdate<CR>
map <silent> , :diffget <CR> :diffupdate<CR>
map <silent> , :diffget <CR> :diffupdate<CR>
map <silent> , :diffget <CR> :diffupdate<CR>

2 Set up git tool

To use vimdiff as default merge tool:

git config --global merge.tool vimdiff
git config --global mergetool.prompt false

3 Resolve merge conflict

Bob and Chen has edited same files. So please merge branch "bob" into "master" at first. Then merge from "chen". The merge conflicts will be created.

git branch         # double check that we got three local branches: master, bob, chen
git checkout master    # set master branch as main branch
git merge bob       #this is ok, because bob is the first one to merge changes
git merge chen       # now some conflicts created because Bob has already edited and merged same files

          Here is the explanation of each buffer:

 
Buffer Explanation Buffer Number
THEIRS contents of the file on the current branch 2
BASE common base for the merge 3
YOURS contents of the file to be merged. 4
MERGED The file containing the conflict markers. You need edit and commit this file. 1

  You could use hot key ",2" (comma + two) ",3" (comma+three) ",4" (comma+four) to pick the content you want to use

   (either THEIRS or BASE or YOURS) to replace the marked conflict in MERGED buffer whose buffer number is one.

  Or you can edit the content directly in MERGED buffer. Anyway, git only care about the the file binding to MERGED buffer.

  Any other buffer will be ignored by git.

  You can use hot key "[c" and "]c" to navigate to previous/next conflict (including the conflict resolved by git automatically) in current file which is binding   to MERGED buffer.

  After finishing editing of the conflicting file in MERGED buffer, you can use hot key ":xa" to exit vimdiff. Git will open next conflicting file with vimdiff   automatically.

  When you have resolved all the conflicts, follow the hint of git to commit your changes.

vimdiff vimmerge 配置及使用的更多相关文章

  1. Git使用指南(1)——Git配置命令

    配置用户信息 git config --global user.name bongxin git config --global user.email bongxin@yeah.net 配置文本编辑器 ...

  2. Linux系统(Centos)下安装nodejs并配置环境

    总结Centos下安装nodejs并配置环境,记录成功安装的方法.推荐的安装方法是利用已编译的二进制文件安装,不推荐使用源码的形式安装,一是源码安装比较麻烦,二是需要自行下载编译浪费时间. 1.安装n ...

  3. git 使用详解(2)——安装+配置+获取帮助

    安装 Git Git 有许多种安装方式,主要分为两种,一种是通过编译源代码来安装:另一种是使用为特定平台预编译好的安装包. 从源代码安装 若是条件允许,从源代码安装有很多好处,至少可以安装最新的版本. ...

  4. git基本操作

    一.在Windows平台上安装Git,可以下载一个msysGit的安装包,点击exe即可安装运行.安装包下载地址:https://git-for-windows.github.io/备注:git命令行 ...

  5. 【使用git】初识git

    0. 版本控制 版本控制是一种记录若干文件内容变化,以便将来查阅特定版本修改情况的系统(vcs). svn等是集中式版本控制,即服务器在单一机器上,每次checkout变化的文件,若机器故障,则有可能 ...

  6. windows上git安装

    Git的官方网站:http://git-scm.com 1.下载:http://msysgit.github.com/ 2.安装 3.配置 用户名.邮箱 这个很重要将来项目提交的账号   $ git ...

  7. git起步

    关于版本控制 什么是版本控制?为什么要版本控制? 版本控制是记录文件内容变化,以便在将来查阅特定版本的系统.有了版本控制,我们就可以将某个文件或是整个项目回退到之前的某个时间段,查看现在和之前相比项目 ...

  8. Ubuntu12.04 GIT安装和使用

    一.安装GIT和配置GIT 1.安装GIT apt-get install git 2.配置GIT ##配置用户信息 git config --global user.name "John ...

  9. 如何在 CentOS7 中安装 Nodejs

    一.安装Nodejs 安装版本:10.13.0 1.安装必要的编译软件包 yum -y install gcc gcc-c++ 2.从源码下载Nodejs cd /usr/local/src wget ...

随机推荐

  1. Redis配置文件解读

    转载自:http://www.cnblogs.com/daizhj/articles/1956681.html 对部分配置选项做了一些说明 把配置项目从上到下看了一遍,有了个大致的了解,暂时还用不到一 ...

  2. DBA_Oracle Erp重启Database/Application/Concurrent/Apache(案例)

    2014-12-27 Created By BaoXinjian

  3. [物理学与PDEs]第5章 弹性力学

    [物理学与PDEs]第5章第1节 引言 [物理学与PDEs]第5章第2节 变形的描述, 应变张量 2.1 变形梯度张量 [物理学与PDEs]第5章第2节 变形的描述, 应变张量 2.2 Cauchy ...

  4. RabbitMQ介绍4 - 编程(C#客户端示例)

    C#终端的说明文档: http://www.rabbitmq.com/dotnet-api-guide.html 这里介绍使用RabbitMQ的几种典型场景. 1. 简单direct模式( http: ...

  5. 十一、jdk命令之Jstatd命令(Java Statistics Monitoring Daemon)

    目录 一.jdk工具之jps(JVM Process Status Tools)命令使用 二.jdk命令之javah命令(C Header and Stub File Generator) 三.jdk ...

  6. CSS如何实现数字分页效果

    代码实例如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...

  7. (Delphi) Windows 32 API程序设计目录

    这里所有程序均使用Delphi调用Windows 32 API方式实现,并不是使用VCL已经封装好的类实现的! (一)第一个窗口程序 01 创建第一个窗口.

  8. Restful API的设计与实践

    Restful这个名称应该很多人都不陌生,但是我发现不少人对Restful存在或多或少的理解偏差,其中不泛比较厉害的程序员,所以有必要为Restful来“正名”. Restful是一种软件架构风格,设 ...

  9. Awk 实例

    AWK 是一种用于处理文本的编程语言工具.AWK 在很多方面类似于 shell 编程语言,尽管 AWK 具有完全属于其本身的语法.它的设计思想来源于 SNOBOL4 .sed .Marc Rochki ...

  10. position中多次用到了relative和absolute,能不能具体介绍一下这两者的区别?

    position中多次用到了relative和absolute,能不能具体介绍一下这两者的区别? 一个是相对定位,一个是绝对定位. absolute生成绝对定位的元素,相对于 static 定位以外的 ...