How do I resolve merge conflicts and failed syncs when using the GitHub Action sync-panther-analysis-from-upstream?
Issue
When trying to keep in sync with upstream using the GitHub Action sync-panther-analysis-from-upstream, the following error occurs:
sync-panther-analysis-from-upstream: all jobs have failed
Resolution
To resolve this issue:
-
Clone your organization’s repo.
-
gh repo clone your-org/panther-analysis-copy
-
-
Checkout the primary branch.
-
git co master
(ormain
)
-
-
Fetch and pull everything from your repo.
-
git fetch && git pull
-
-
Checkout the sync branch.
-
git checkout sync_upstream_v1.44.0
-
Make sure to replace 1.44.0 with the correct version.
-
-
-
Ensure that you have the upstream panther-analysis as a git remote.
-
git remote -v
-
If not, please follow the section below titled "Add upstream panther-analysis as a git remote."
-
- Fetch the upstream.
git fetch upstream
-
Merge in the failing upstream branch to your local sync branch.
-
git merge v1.44.0
-
Make sure to replace 1.44.0 with the correct version.
-
-
-
Resolve the merge conflicts.
-
Run
git status
to check your status. -
Resolve the merge conflicts:
-
Take the file from upstream:
-
git checkout --theirs $filename
-
-
Keep the local edits and discard upstream’s changes:
-
git checkout --ours $filename
-
-
If you need to make other changes:
-
edit $filename
-
-
-
Add the conflicting file as resolved:
-
git add $filename
-
-
-
After addressing the files, you can commit the changes:
git commit
-
Push the resolved merge to your local sync branch
-
git push origin sync_upstream_v1.44.0
-
Make sure to change 1.44.0 to the correct version.
-
-
Now you can open a pull request from your local sync branch to your local repo.
Add upstream panther-analysis as a git remote
If you do not have the upstream panther-analysis as a git remote, follow these instructions to add it:
- git remote -v
- git remote add upstream https://github.com/panther-labs/panther-analysis.git
- git remote -v
Cause
Merge conflicts and related issues can be occur for a variety of reasons depending on changes that have been made downstream. They typically occur when two separate branches have made edits to the same line in a file, or when a file has been deleted in one branch but edited in the other.