- Go to the main branch:
git checkout main
- Then run :
git fetch origin main
- Go to other branch and run :
git merge --no-commit --no-ff origin/main
The --no-commit option prevents Git from automatically committing the merge changes, which gives you an opportunity to review the changes and resolve any conflicts that may arise.
The --no-ff option forces Git to create a new merge commit instead of fast-forwarding the child branch to the parent branch. This ensures that the child branch history remains separate from the parent branch history.