Naama L Ackerman
Naama L Ackerman

Reputation: 169

How to create and apply git patches between two identical repos with mismatching commit IDs

I shallow-cloned a git repo from GitHub and moved it to an isolated private gitlab server. In order to push the shallow clone to the new repo, I had to lose the commit IDs and tags (I used this answer: link).

Now I want to create git patches externally and moved them to the private gitlab server in order to keep the private project updated. But I understand that git patches rely on persistent commit SHAs to work - And the commits SHAs in the two projects do not match.

Is there a way for me to create usable patches?

Upvotes: 1

Views: 90

Answers (1)

VonC
VonC

Reputation: 1324218

But I understand that git patches rely on persistent commit SHAs to work

Yes, if you are using git am to apply the patches generated by git format-patch (as seen here)

git format-patch <first-commit-hash>^..<end-commit-hash>

But if you are using git apply, you should be able to apply those path to your current working directory, without checking for the right SHA1.
See "What is the difference between git am and git apply?".

Upvotes: 1

Related Questions