DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1
# git merge newfeature
Updating 77f786a..dd6bce5
Fast-forward
text1 | 1 +
1 file changed, 1 insertion(+)

In this very simple example, no changes were made to
the master branch, and Git was able to automatically
merge the two branches and create a new combined
commit that had the new content from the newfeature
branch. Notice that the output above says “Fast-
forward”; this refers to updating past the changes in the
branch, which is much like fast-forwarding through the
boring parts of a movie. At this point, you can delete the
branch newfeature, as the code in it has been moved to
master. Figure 2-17 illustrates how this is done: Git
creates a new commit that has two sources.


Figure 2-17 Git Merge Between Two Branches


Handling Conflicts


Merging branches is a very useful capability, but what
happens if the same file is edited by two different
developers? You can have a conflict in terms of which
change takes precedence. Git attempts to handle merging
automatically, but where there is conflict, Git relies on
human intervention to decide what to keep. In the
previous example, if there had been changes made to
text1 in both the master branch and the newfeature

Free download pdf