git merge
combines changes from two branches. Its primamry purpose is to integrate changes made in one branch (source branch) into another (target branch) and share those changes with other developers.
The master
or main
branch in Git is a repository's default and primary branch. It usually represents the latest stable version of the project's code.
-
Switch to
master
branchdev@dev:~/your-project$ git switch master
ℹ️ NOTE
Ensure you are on the branch you want to merge into.
-
Merge the
y
branch intomaster
branchThis will merge the
[branch-name]
to the current branch.dev@dev:~/your-project$ git merge [branch-name]
ℹ️ NOTE
Remember to replace
[branch-name]
with your branch name (e.g.develop
).Example:
git merge develop
-
Push the local changes to the remote repository
dev@dev:~/your-project$ git push -u origin master