Junior — Middle
Can you explain how branch merging is done in Git using the merge command?
sobes.tech AI
Answer from AI
The git merge command is used to combine changes from one branch into another. When executing git merge <branch>, Git attempts to automatically merge commits from the specified branch into the current one. If there are no conflicts, a new merge commit is created that combines the history of both branches.
Example:
# Switch to the master branch
git checkout master
# Merge the feature branch into master
git merge feature
If there are conflicts, Git will ask you to resolve them manually, after which you need to run git add and git commit to complete the merge.