Sobes.tech
Junior — Middle

How can a commit be moved from one Git branch to another?

sobes.tech AI

Answer from AI

To move a commit from one Git branch to another, you can use the git cherry-pick command. It allows you to apply a specific commit from one branch to another.

Example:

# Switch to the target branch
git checkout target-branch

# Apply the commit by its hash
git cherry-pick <commit-hash>

If you need to move multiple commits, you can specify a range or multiple hashes. After that, the commits will be added to the current branch.