Before merging, make sure your branch is up-to-date with the latest changes from the main branch. You can do this by pulling the latest changes:
git checkout dev
git pull origin dev
git checkout your-feature-branchIf there are any conflicts between your branch and the main branch, resolve them locally before attempting to merge. Use a merge tool or manually edit the conflicting files.
git merge devIf conflicts occur, Git will mark the conflicted files. After resolving conflicts, mark them as resolved:
git add <conflicted-file>Before merging, ensure that your changes work as expected. Run tests and perform any necessary validation.
Commit your changes to the feature branch after resolving conflicts and testing:
git commit -m "Merge main into feature branch and resolve conflicts"Push your branch with the new merge commit to the remote repository:
git push origin your-feature-branchIf you're working with a platform like GitHub, GitLab, or Bitbucket, create a pull request (PR). This allows your changes to be reviewed before merging into the main branch.