How to merge one branch to another in Git?
First move to the branch where you want the changes (the target), and then run git merge with the name of the branch to bring in.
Example: merge dev into main.
Terminal output
$ git switch main
Already on 'main'
$ git merge dev
Updating a17f7f4..5a62a93
Fast-forward
new.html | 1 +
1 file changed, 1 insertion(+)
create mode 100644 new.html
If both branches changed the same lines, Git shows a conflict which you must solve by hand. See Git Merge and Git Merge Conflict.
Learn more about the similar topics:
| Tutorials |
|---|
| Git Branch |
| Git Checkout and Switch |
| Git Merge |
| Git Merge Conflict |
| Git Rebase |
| Git Cherry Pick |
| Git Branching Strategy |