Skip to content

Instantly share code, notes, and snippets.

@tamalCodes
Last active June 14, 2023 04:02
Show Gist options
  • Select an option

  • Save tamalCodes/bde31cb03450f33030f9b686863ec48c to your computer and use it in GitHub Desktop.

Select an option

Save tamalCodes/bde31cb03450f33030f9b686863ec48c to your computer and use it in GitHub Desktop.
My way to compare and update to 2 branches

Steps followed

  • 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

Commiting it

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.

Review the changes and resolve any conflicts that may arise.

Commit the merge changes with a descriptive commit message: git commit -m "fix: merge changes from main to xyz"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment