Merging Branch
Last updated
Last updated
Branching makes it super easy to work within self-contained context,But often we want to incorporate changes from one branch into anther !
we can do this using the git merge
command
The merge command can sometimes confuse students early on.Remember these two merging concepts :
We merge branches , not specific commits
We always merge to the current HEAD branch
To merge , follow these basic steps :
Switch to or checkout the branch you want to merge the change into . (the receiving branch)
Use the git merge
command to merge changes from a specific branch into the current branch
In history , we checkout branch FIXBUG
in a point and develop a feature . When we done , we merge current branch into master branch . Master branch and ABABA
branch beside on point . This called faster-forward
after merging
this happen all the time ! Images one of your teammate merge in a new feature or change to master while you were working on a branch
Some Depending on the specific changes your are trying to merge , Git may not be able to automatically merge. This result in merge conflicts
, wwhich you need to manually resolve
Whenever you encounter merge conflicts , follow these steps to resolve them :
step 1 : Open up the file (s) with merge conflicts
step 2 : Edit the file(s) to remove the conflicts . Decide which branch's content you to keep in earch conflict . Or keep the content from both
step 3: Remove the conflicts markers
in the document
step 4 : add your changes and then make a commit !