...

Open source softwares - GIT

Back to Course

Lesson Description


Lession - #1147 Git Branch Merge


How do I merge one branch to another?
To merge branches regionally, use git checkout to change to the branch you wish to merge into. This branch is typically the main branch. Next, use scum bag merge and specify the name of the other branch to bring into this branch.



Example
First, we need to change to the master branch:


git checkout master
Switched to branch 'master'


Now we merge the current branch (master>
with emergency-fix:


git merge emergency-fix
Updating 09f4acd..dfa79db
Fast-forward
index.html | 2 +-


one file modified, 1 insertion(+>
, 1 deletion(->


Since the emergency-fix branch came directly from master, and no other changes had been made to master while we were working, git sees this as a continuation of master.

What is a git Merge Conflict?
A merge conflict is an event that takes place once git is unable to automatically resolve differences in code between 2 commits. git will merge the changes automatically only if the commits are on totally different lines or branches.

What causes git merge conflict?
Git will handle most merges on its own with automatic merging features. A conflict arises once 2 separate branches have created edits to the same line in an exceedingly file, or once a file has been deleted in one branch but edited within the other. Conflicts can most likely happen once working in a team environment.