質問

How could I merge several, selected commits from branch B into A. I did this but I am not sure if there is a one line solution for this:

git log -p -1 B~~ | git apply
git log -p -1 B~ | git apply
git commit -m 'Merge penultimate and before penultimate B commits into A'
役に立ちましたか?

解決

Use git cherry-pick

In your case (when branch A is your current HEAD):

git cherry-pick B~1

他のヒント

For applying selected commits use cherry-pick.


UPD: totally agreed with @jmh comment. Merge commit as you know is just another usual commit but with many child commits. It is not like applying all commits from different branch.

So if you wanna apply some specific commits from different branch, cherry-pick will work here fine.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top