Resolving merge conflicts in Git: Difference between revisions
From genomewiki
Jump to navigationJump to search
(Initial Page Setup) |
(Added Tools: Git Status) |
||
Line 6: | Line 6: | ||
# Changes are staged by not committed | # Changes are staged by not committed | ||
# Changes are committed but Git could not resolve merge on its own | # Changes are committed but Git could not resolve merge on its own | ||
==Tools== | |||
Tools and example output when in a merge conflict situation. | |||
===Status=== | |||
The git status command provides an overview of all files that have been modified and are in conflict at the time of the merge. | |||
Example: | |||
git status | |||
# Changes to be committed: | |||
# (use "git reset HEAD <file>..." to unstage) | |||
# | |||
# modified: <Some file> | |||
# | |||
# Changed but not updated: | |||
# (use "git add <file>..." to update what will be committed) | |||
# (use "git checkout -- <file>..." to discard changes in working directory) | |||
# | |||
# unmerged: <file> | |||
# | |||
* "Changes to be committed": All changes to files that are not affected by the conflict are staged. | |||
* "Changes but not updated": All files that have conflicts that must be resolved before repository will be back to working order. | |||
==Scenarios== | ==Scenarios== | ||
Line 24: | Line 51: | ||
Error Message: | Error Message: | ||
# | # | ||
CONFLICT (content): Merge conflict in <fileName> | |||
Automatic merge failed; fix conflicts and then commit the result. | |||
Steps toward Resolution: | Steps toward Resolution: |
Revision as of 20:25, 1 March 2011
Why would my Merge Fail?
There are 3 scenarios that could result in a Failed Merge.
- Changes are only in your working directory
- Changes are staged by not committed
- Changes are committed but Git could not resolve merge on its own
Tools
Tools and example output when in a merge conflict situation.
Status
The git status command provides an overview of all files that have been modified and are in conflict at the time of the merge.
Example:
git status
# Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: <Some file> # # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # unmerged: <file> #
- "Changes to be committed": All changes to files that are not affected by the conflict are staged.
- "Changes but not updated": All files that have conflicts that must be resolved before repository will be back to working order.
Scenarios
Git refuses to start a merge/pull
Error Messages:
- error: Entry '<fileName>' not uptodate. Cannot merge. (Changes in working directory)
- error: Entry '<fileName>' would be overwritten by merge. Cannot merge. (Changes staged, but not commited)
Steps toward Resolution:
- 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.)
- git status ( Verify all changes are staged)
- git stash list (Lists all stash's user has)
- git pull or git merge (Bring in changes from central repository or another branch)
- 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:
- git status (Shows all files that are in conflict as unmerged changed in working directory.)
- Resolve Merge confilicts
- git add <files>
- git commit -m "<Informative commit message>"