Skip to content

Scenarios for Advanced Input

Adam Ormsby edited this page Mar 9, 2024 · 5 revisions

Many sync use cases are not covered by default configurations. This page is a running running list of optional settings to assist with your needs. I encourage you to share your unique configurations if you have needed something special to solve your use case.

Sync to branch under active development

This sync action will not handle merging commit conflicts for you. However, you can implement basic conflict selection between 'theirs' or 'ours' using the upstream_pull_args input.

  • Keep upstream repo commits => upstream_pull_args: '-s recursive -Xtheirs'
  • Keep target repo commits => upstream_pull_args: '-s recursive -Xours'

Target/upstream branches don't share common ancestor

For example - you forked a repo, and then you added this action to the default branch of the repo to keep it synced with the matching upstream branch. Now your target and upstream branches have divergent histories. The sync fails with a git error.

  • fatal: refusing to merge unrelated histories

This can also happend if you commit your work to the branch you're syncing. Add this to allow divergent histories to be merged.

  • upstream_pull_args: '--allow-unrelated-histories'

When one of your repositories is a shallow clone

My current understanding of this is that either the target repo or the upstream repo get checked out as a shallow copy of the repo, but the other doesn't. This could happen if you set the --depth option on a pull or fetch, and it can result in an error:

  • fatal: refusing to merge unrelated histories

It's a somewhat misleading error. Instead of allowing unrelated histories, you might try to use the --unshallow option in your upstream_pull_args input.

--unshallow
    If the source repository is complete, convert a shallow repository
    to a complete one, removing all the limitations imposed by shallow
    repositories.

    If the source repository is shallow, fetch as much as possible so
    that the current repository has the same history as the source
    repository.