Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Merge conflicts with Git

Merge conflicts with Git

An introduction to the workflow for solving merge conflicts with Git

Avatar for Francesco Gigli

Francesco Gigli

November 22, 2012

Other Decks in Technology

Transcript

  1. I'll just merge this and go to the pub.. $

    git merge parsing Auto-merging rubrica.py CONFLICT (content): Merge conflict in rubrica.py Automatic merge failed; fix conflicts and then commit the result.
  2. $ git reset --hard HEAD is now at ee0e7af updated

    documentation $ cd /pub $ more beer Your old commit is still there! image from http://www.ebay.co.uk/itm/8W-Low-Energy-Maintained-Metal-3-Hrs-Emergency-Exit-Box-Legend-EBM8-/380575955600
  3. merge: a commit with two parents The commit e is

    a merge of d and d1 There is nothing special about it
  4. Take a look at the current status $ git status

    # On branch master # Changes to be committed: # # modified: .gitignore # new file: staff_contact_details.htm # new file: test.py # # Unmerged paths: # (use "git add/rm <file>..." as appropriate to mark resolution) # # both modified: rubrica.py #
  5. Take a look at the history $ git log --merge

    --oneline 40c3b7b Use re.findall and match on Adam Gibbins ee1b078 Login to the wiki git log --merge shows only the conflicting commits
  6. Conflict markers are so 20th century.. $ git mergetool merge

    tool candidates: meld opendiff kdiff3 tkdiff xxdiff tortoisemerge gvimdiff diffuse ecmerge p4merge araxis bc3 emerge vimdiff Merging: rubrica.py Normal merge conflict for 'rubrica.py': {local}: modified file {remote}: modified file Hit return to start merge resolution tool (meld):
  7. $ git mergetool --tool meld merge tool candidates: meld opendiff

    kdiff3 tkdiff xxdiff tortoisemerge gvimdiff diffuse ecmerge p4merge araxis bc3 emerge vimdiff Merging: rubrica.py Normal merge conflict for 'rubrica.py': {local}: modified file {remote}: modified file Hit return to start merge resolution tool (meld): Meld FTW!
  8. $ git mergetool --tool diffuse merge tool candidates: meld opendiff

    kdiff3 tkdiff xxdiff tortoisemerge gvimdiff diffuse ecmerge p4merge araxis bc3 emerge vimdiff Merging: rubrica.py Normal merge conflict for 'rubrica.py': {local}: modified file {remote}: modified file Hit return to start merge resolution tool (meld): ..or diffuse maybe?
  9. At some point all tests are green $ git add

    rubrica.py $ git commit Merge branch 'parsing' Conflicts: rubrica.py # # It looks like you may be committing a merge. # If this is not correct, please remove the file # .git/MERGE_HEAD # and try again.