Resolving merge conflicts in Git

From genomewiki
Revision as of 20:12, 1 March 2011 by Vsmalladi (talk | contribs) (Initial Page Setup)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Why would my Merge Fail?

There are 3 scenarios that could result in a Failed Merge.

  1. Changes are only in your working directory
  2. Changes are staged by not committed
  3. Changes are committed but Git could not resolve merge on its own

Scenarios

Git refuses to start a merge/pull

Error Messages:

  1. error: Entry '<fileName>' not uptodate. Cannot merge. (Changes in working directory)
  2. error: Entry '<fileName>' would be overwritten by merge. Cannot merge. (Changes staged, but not commited)

Steps toward Resolution:

  1. git stash save "<Message that describes what is being Saved>" (Stashes away any changes in your staging area and working directory in a separate index.)
  2. git status ( Verify all changes are staged)
  3. git stash list (Lists all stash's user has)
  4. git pull or git merge (Bring in changes from central repository or another branch)
  5. git stash pop (Will repopulate your changes into your working directory, maybe have to resolve merge conflicts)

Git is unable to resolve a merge/pull

Error Message:

 CONFLICT (content): Merge conflict in <fileName>
 Automatic merge failed; fix conflicts and then commit the result.

Steps toward Resolution:

  1. git status (Shows all files that are in conflict as unmerged changed in working directory.)
  2. Resolve Merge confilicts
  3. git add <files>
  4. git commit -m "<Informative commit message>"