Cherry pick only captures for a specific file

What is a short way to request "cherry picks from another branch only commits that relate to a particular file"? those. the command git log ..other-branch afilegives a list of unrelated commits in another branch that relate to the "file"; How can I request a re-play of the same set of commits in the current branch?

+3
source share
1 answer

git cherry-pick $(git log --reverse --pretty=format:"%H" filename)

Gotta do the trick. git log --reverse --pretty=format:"%H" filenamebasically gives you a new SHA list of all commits that you modified filenamein the reverse order to commit the merge in the correct order. Then we pass the list to git cherry pick.

git cherry-pick $(git rev-list --reverse HEAD -- filename) - This is another version of the aforementioned team provided by Magnus Beck.

+3
source

All Articles