Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the *right* way to apply a patch from another branch?

Tags:

git

I make a fix in one branch and want to apply it to another branch. Here's what I have been doing:

git diff 68610d^ 68610d | git apply
git commit -a -m "SV-656  IP blocking not working  (applying patch from 68610d)"

works perfectly but it occurs to me, it doesn't seem like a very git-like way to do things. In particular, what I am actually doing is only apparent from the comment. This is a very basic activity and I don't think git would have missed it.

EDIT: is this the function of "cherry-pick"?

like image 341
Michael Lorton Avatar asked Nov 28 '11 00:11

Michael Lorton


1 Answers

The correct way would be

git cherry-pick 68610d

If your really wanted to alter the commit message:

git cherry-pick --no-commit 68610d
git commit -m "SV-656  IP blocking not working  (applying patch from 68610d)"
like image 192
sehe Avatar answered Sep 27 '22 15:09

sehe