Git: How do you merge a file with a version of itself from a previous commit? -


there changes made file in commit a, undid changes mistake , went on further make changes in commits b , c.

i want changes in commit in file, changes in b , c should not lost either.

let's branch @ c.

i don't want

$ git checkout --patch  

because want file contain changes made in b , c , doing checkout of file commit rewrite file in both index , working tree.

i can't cherry-pick because commit merge commit(there 2 contributors repository , deleted changes mentor made mistake in subsequent commits after merged them) , might end mess if specified either parent.

apart manually copying changes want in file, there other way accomplish this?

you can create patch , attempt apply patch. if experience issues conflicts such

error: patch failed: <file_name>:1 error: <file_name>: patch not apply 

the merge require manual intervention.

here's example:

$ git format-patch -n <sha_from_commit_you_want_to_merge> > patch_file.patch $ git apply patch_file.patch 

it possible strategy still problematic because of nature of commit a. cannot separate constituent components of merge commit without access branch whence individual commits made. branch/repo sees 1 commit.

of course if do have access original branch can create patch file there, even if in different repositories.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -