Sobes.tech
Junior — Middle

What methods do you know for merging changes from different branches in Git?

sobes.tech AI

Answer from AI

In Git, there are several ways to combine changes from different branches:

  1. merge — the classic method that creates a new merge commit, combining the history of both branches. Example:
git checkout main
git merge feature-branch
  1. rebase — moves commits from one branch onto another, creating a more linear history. Example:
git checkout feature-branch
git rebase main
  1. cherry-pick — selectively applies individual commits from another branch.
git cherry-pick <commit-hash>
  1. fast-forward merge — if the branch being merged into has no new commits, it simply moves the branch pointer forward.

Each method has its pros and cons; the choice depends on the desired history and situation.

What methods do you know for merging changes from… - sobes.tech