We create branches to have another version or enhanced version of our project separately. We need branches to be able to work collaboratively and also have in progress version of our project without breaking the stable version of our project. When the development in branch is done and we decide to apply changes into our master or main branch we need to merge the branch to the main. Git will check both branches for differences and if there is no conflict, then the merge will be executed and all the changes in branch will be applied to the target branch.
git merge new-fix
This command will merge the branch named new-fix into the current branch. So if we want to merge new-fix to our main, before merging we should checkout to main branch first.
Conflict can happen if you stage the changes but did not commit and then checkout to main and run merge. As the new-fix branch had some staged changes and not committed, thus git is not able to decide which changes should be merged