Search code examples
gitrepositorybitbucketcommit

Can we use/pick-up commit of one program into another similar program?


I have two similar programs(with almost same file hierarchy) with some differences and both are separate bitbucket repository. I have added some feature in the first program and wondering of using its commits to reproduce the same feature in the second program?

It maybe a silly idea as programs are separate, but I am thinking that way because the files I have modified have exactly the same hierarchy in both the repositories. Is it feasible to do anything like that? Or I have to manually copy/paste the changes...

UPDATE:

As suggested in comment by Enrico Campidoglio, one of the solution approach for this can be by using diff and format-patch mentioned here: Create patch or diff file from git repository and apply it to another different git repository


Solution

  • You should export each single commit by:

    git format-patch -{NUMBER_OF_BACKWARD_COMMITS} {STARTING_COMMIT_HASH} --stdout > diff.patch

    Then apply the patch generated file on the other repository by:

    git am < diff.path.