Difference between revisions of "Git/merge"
< Git
Jump to navigation
Jump to search
(process) |
(another relevant chapter) |
||
Line 28: | Line 28: | ||
* [https://www.kernel.org/pub/software/scm/git/docs/git-merge.html manpage @ kernel.org] | * [https://www.kernel.org/pub/software/scm/git/docs/git-merge.html manpage @ kernel.org] | ||
===How To=== | ===How To=== | ||
+ | * [http://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging 3.2 Git Branching - Basic Branching and Merging] | ||
* [http://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging 7.8 Git Tools - Advanced Merging] | * [http://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging 7.8 Git Tools - Advanced Merging] |
Revision as of 16:59, 11 August 2015
Action: join two or more development histories together
"Incorporates changes from the named commits (since the time their histories diverged from the current branch) into the current branch. This command is used by git pull to incorporate changes from another repository and can be used by hand to merge changes from one branch into another."
Things to remember:
- It's better to have all changes committed before you try a merge.
- If the merge fails, you can "back out" with
git merge --abort
. - If things get too ugly and you just want to revert to a known state,
git reset --hard <commit>
blows away all uncommitted changes and reverts to the given commit.
Process
This is incomplete; documentation will be ongoing as I figure out how this works.
When you do a git pull in which there are conflicts between the remote and local versions, the following will happen:
- Git will attempt to "auto-merge" each conflicting file.
- For each file, there will be a message saying whether the merge was successful.
- If the merge is not successful, the local file will be marked up with notes indicating the differences between versions. The markup format seems to be:
- <<<<<<< HEAD
- text of local version
- =======
- text of remote version
- >>>>>>> long hexadecimal identifier
- What's not clear yet is what to do after resolving the conflicts, or how to indicate that they are resolved. Possibly it should be:
- Save all files the way you want them to be.
- git add the changes back into the staging area.
- git commit the changes.
- git push the committed changes back to the remote.