Merging GitHub Branches
How to merge GitHub Branches
When you create a branch for a new feature with Git, you are ostensibly making a separate file (forking) that will have no larger effect on the main project file until you are ready to merge that branch. Merging is a means of putting forked files, or branches, back together. When you merge a branch into your main project file, you are fusing the two files and all their working code back into a single branch.
Using the command git merge takes all commits from a secondary or tertiary feature branch and integrates it with the main working branch to form a consolidated history of commits. Git merge does this by identifying a common ancestor in the commit history of both branches (as shown above). This common ancestor commit is used by git to create a new merge commit that will fuse the differences of each branch into a singular sequence.
You must be on the receiving branch before merging. To merge secondary branches into your main branch you must be working on the main branch in your code editor. You can use the git status terminal command to see what branch you are currently on. If necessary, use terminal command git checkout main to switch to that branch.
Make sure that all branches are up to date by using terminal command git fetch on both main and feature branches, and then execute git pull on your main branch.
Once all of these steps are complete and you are on the main branch in your code editor, use git merge <feature-branch-name> to merge the given feature branch into your main branch.
I hope this was helpful and thanks for reading!
Further Reading and Sources
Git Merge | Atlassian Git Tutorial
Merging is Git's way of putting a forked history back together again. The git merge command lets you take the…
About merge methods on GitHub - GitHub Docs
You can configure pull request merge options on GitHub.com to meet your workflow needs and preferences for managing Git…