You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’ve used rsync in the past but unfortunately I’m not deeply familiar with all of its features.
My main concern about using rsync is that it clobbers the local files, and that then results in a larger change set and possible merge conflicts. I’ve been scratching my head about that for a while now, and wanted to share an alternative to the rsync approach:
Check out the downstream repository as usual, and not into a subfolder;
Add this upstream template repository as a remote (docs):
Merge from the upstream repository and ask git to prefer upstream changes (docs):
git merge --squash --allow-unrelated-histories --no-commit --strategy ort --strategy-option theirs <REF># Where <REF> can be `main` or some other git ref.
By using the theirs option for the default merge strategy ort we tell git to prefer the upstream changes for merge conflicts.
Judging from a few local tests, this allowed me to merge the upstream changes into an independent private repository without merge conflicts; however, the resulting change set lost a few local changes, e.g. the package name of my repository whose merge conflict was resolved using the upstream template’s package name. But maybe that’s ok, because we need to review and adjust the PR anyway 🤔
I do wonder if it’s possible to configure the merge driver such that I can change the strategy option of the ort strategy for certain hunks: for example, the Makefile should merge using the theirs option except for the hunk covering line 7
where I’d like to either exclude a merge completely or merge with the ours option.
It might also be worth digging around here or here.
Regarding those files/path we want to exclude from the automatic merge (e.g. here): that doesn’t really seem to be doable with git but perhaps a simple git restore after the above merge would do?
The text was updated successfully, but these errors were encountered:
IMO a better option would be to generate a patch with the desired changes from the template repository and apply it to the target repository.
This way there is a little more control over the merge conflicts, like leaving the conflicts in the file with conflict markers, as done on getpassport/template_services_python#435 and improved on getpassport/template_services_python#439.
I’ve used
rsync
in the past but unfortunately I’m not deeply familiar with all of its features.My main concern about using
rsync
is that it clobbers the local files, and that then results in a larger change set and possible merge conflicts. I’ve been scratching my head about that for a while now, and wanted to share an alternative to thersync
approach:git
to prefer upstream changes (docs):theirs
option for the default merge strategyort
we tellgit
to prefer the upstream changes for merge conflicts.Judging from a few local tests, this allowed me to merge the upstream changes into an independent private repository without merge conflicts; however, the resulting change set lost a few local changes, e.g. the package name of my repository whose merge conflict was resolved using the upstream template’s package name. But maybe that’s ok, because we need to review and adjust the PR anyway 🤔
I do wonder if it’s possible to configure the merge driver such that I can change the strategy option of the
ort
strategy for certain hunks: for example, the Makefile should merge using thetheirs
option except for the hunk covering line 7python-package-template/Makefile
Line 7 in 4e0a9aa
where I’d like to either exclude a merge completely or merge with the
ours
option.It might also be worth digging around here or here.
Regarding those files/path we want to exclude from the automatic merge (e.g. here): that doesn’t really seem to be doable with
git
but perhaps a simplegit restore
after the above merge would do?The text was updated successfully, but these errors were encountered: