###Overview: A quick exercise in using vimdiff to merge conflicted git files http://www.rosipov.com/blog/use-vimdiff-as-git-mergetool/ git {branch,checkout,merge}
###Set up
git config --global merge.tool vimdiff
git config --global merge.conflictstyle diff3
git config --global mergetool.prompt false
####Create Merge Problem Make a new repo with a committed text file, then create a new branch. In the new branch, edit and commit changes to the text file. Switch back to the master branch, then attempt to merge
mkdir zoo
git init
vi animals.txt #add a list of animals
git add animals.txt
git commit -m "initial commit"
git branch newbranch # create a new branch
git checkout newbranch # changes to a new branch
vi animals.txt # make a change to the list of animals
git add animals.txt
git commit -m "update to animals.txt"`
git checkout master
git merge newbranch # this will cause a problem
####Fix Merge Problem The merge should have been aborted, as there are files in conflict. Fix the problem with git mergetool. There will be 4 files in the vim editor. LOCAL - the file from the current branch. BASE - the common ancestor. and REMOTE - the version of the file from 'new branch' MERGED - the file you are merging into your branch git mergetool
####Using vimdiff
- use
Ctrl-w [jklh]
orCtrl-w [arrow key]
to move to the MERGED file. - To select a conflict, move your cursor over the highlighted text
:diffg [RE,BA,LO]
will get from[REMOTE,BASE,or LOCAL]
Save the file with :wqa
####Problem Solved the following should now work
git commit -m "fixed merge problem