How can I avoid overwriting global helpers while using PAT?
I accidentally overwrote some Python helper files using PAT. Is there any way to ensure we don't overwrite global helpers?
If you have overwritten panther distributed content in the global_helpers directory, we recommend the following process to get back in sync. The overall process is to add a git remote for upstream ( panther-labs/panther-analysis ) and then use git restore to pull the content from upstream while keeping any local files that did not come from upstream.
Check out your git repository, and create a branch to get back in sync.a. This process is detailed in Steps 1-3 of the Resolution section of this KB article: How do I resolve merge conflicts and failed syncs when using the GitHub Action sync-panther-analysis-from-upstream?
Create a branch inside your git repositorya.
git checkout -b fix/sync_global_helpers
Add a git remote named upstream, which is panther-labs/panther-analysisa.
git remote add upstream https://github.com/panther-labs/panther-analysis.git
Fetch content from upstreama.
git fetch upstream
You can see what’s different in global_helpers at this point if you wisha.
git diff fix/sync_global_helpers..upstream/master global_helpers
b. The left-hand side of the diff ( minuses ) are our local changes, with the right-hand side representing upstream
Now use git restore to replace content in global_helpers with stuff from panther-labs/panther-analysis. This command should leave any files that you have added to global_helpers in place.a.
git restore --source=upstream/master --staged --worktree --overlay -- global_helpers
i. This only syncs the global_helpers directory
Check out the delta with git statusa.
Commit this sync to your local brancha.
Push your branch up and PR it to your repoa.
git push origin fix/sync_global_helpers
b. Click the link for the PR.
Delete the upstream git remotea.
git remote remove upstream