wsha
wsha

Reputation: 964

Pick Commits from different branches into main branch

I have 3 branches:
- master
- feature1
- feature2

Feature1 & Feature2 have common code which is independent and has several commits, How do i pick individual commits from f1 and f2 into master?

Upvotes: 0

Views: 25

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 522752

You can use git cherry-pick. For example, if you wanted to copy a commit from feature1 whose hash was a43kbjhl to master, you could do the following:

git checkout master
git cherry-pick a43kbjhl

And you can repeat the above step for all the commits you want to cherry pick. Keep in mind that if you actual inspect the commits you have copied over, their SHA-1 hashes actually won't match the originals. This is because Git has created new commits for each cherry-pick.

Upvotes: 2

Related Questions