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.
source
share