Skip to main content
Panther Knowledge Base

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.

The steps:

  1. 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?
  2. Create a branch inside your git repository

    a. git checkout -b fix/sync_global_helpers
  3. Add a git remote named upstream, which is panther-labs/panther-analysis

    a. git remote add upstream
  4. Fetch content from upstream

    a. git fetch upstream 
  5. You can see what’s different in global_helpers at this point if you wish

    a. 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 
  6. 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
  7. Check out the delta with git status

    a. git status
  8. Commit this sync to your local branch

    a. git commit
  9. Push your branch up and PR it to your repo 

    a. git push origin fix/sync_global_helpers
    b. Click the link for the PR.
  10. Delete the upstream git remote

    a. git remote remove upstream