Mohamed Mufeed
Mohamed Mufeed

Reputation: 1560

How to apply same set of changes to different repos using git?

I have different repositories that are all ultimately copied from one repo. But these repos don't contain the commit history of one another.

i.e.,

The question is How do I go about applying those changes to Y, L, M, N?

Do I need to manually repeat all of the changes on all repos or is there a better way?

Upvotes: 2

Views: 593

Answers (2)

Mohamed Mufeed
Mohamed Mufeed

Reputation: 1560

After a bit of struggle I have managed to work it out. For future reference for any body having the same issue I am posting my solution here

first create the patch (thanks to Mureinik's answer)

git format-patch --ignore-space-change -1 <cimmit_hash>

then apply the patch using the unix patch utility instead of git am

 patch -p1 --binary --merge -l < ../path/to/your/patch/file

This will get you to a point where you can manage manually.

Upvotes: 0

Mureinik
Mureinik

Reputation: 311163

You could use git format-patch in the X project to create a patch file(s). There are many flags there, but in the simple usecase, you usually care about two of them - -n specifies how many commits from the HEAD will be stored in patch files, and -o specifies the target directory for them. E.g.:

mureinik@computer ~/src/git/x (master)
$ git format-patch -n1 -o /tmp
/tmp/0001-some-commit.patch

Then, you can use git am in the other project(s) to apply those patches. If they apply cleanly, you'll just get another commit in the project. If there are conflicts, you'll have to resolve them:

mureinik@computer ~/src/git/y (master)
$ git am /tmp/0001-some-commit.patch
Applying: Some commit

Upvotes: 2

Related Questions