Reputation: 57
How to merge old commit code into HEAD? If I want to merge the complete file of test.js at commit hash e123ee12
in to HEAD test.js.
I try to using cherry-pick but if there are many commit before I need to cherry-pick one by one.
I also try to checkout to the e123ee12
and add a empty line then commit and checkout back to master and merge the commit.But it will only merge the line that I add,will not merge all line to the master.
How to merge all file at old commit into master?
Upvotes: 1
Views: 245
Reputation: 1328652
You could try and generate a patch from that old commit (including for a single file)
git format-patch -1 <sha> -- aFile
Then apply it to your current HEAD
git am -3 < file.patch
Note: for multiple commits, you can cherry-pick a range of commits.
Upvotes: 1