Merging

Branching makes it super easy to work within selfcontained contexts, but often we want to incorporate changes from one branch into another. We can do this using the git merge command

Remember these two merging concepts:


To merge, follow these basic steps:

	
	git switch master  =>  Switch to the master branch
	
	git merge branchName   =>  merge branchName to master branch
	

What happen if we add a commit on the master branch and then try to merge

Imagine one of our teammates merged in a new feature or change to master while we were working on a branch. If we try to merge branch to master branch then git will prompt a merge conflict issue and our merge will not be done. which we need to manually resolve.

When we encounter a merge conflict, Git warns us in the console that it could not automatically merge and It also changes the contents of our files to indicatethe conflicts that it wants us to resolve.

		
	<<<<<<< HEAD
	
	Some lines 
	
	=======
	
	Some lines 
	
	>>>>>>> bug-fix
	

<<<<<<< HEAD
Some lines
The content from your current HEAD (the branch we are trying to merge content into (master) is displayed here.

Some lines
>>>>>>> bug-fix
The content from your current HEAD (the branch we are trying to merge content into (master) is displayed here.


Resolving Conflicts

Whenever we encounter merge conflicts, follow these steps to resolve them: