Force Git to overwrite local changes if there is a branch conflict

Use code you find here at your own risk! I am not responsible if you damage your data or system by following any instructions you find here.

  1. Navigate to your plugin’s root directory:

    Bash

    <span class="hljs-built_in">cd</span> /home/kupietzc/public_html/kartscode/wp-content/plugins/ktwp-draggable-elements

  2. Fetch the latest changes from GitHub:
    Bash

    git fetch origin

  3. Perform a hard reset to match GitHub’s main branch (assuming main is your branch):

    Bash
    git reset --hard origin/main

    WARNING: This command is destructive. It will discard all local changes to tracked files and make your local repository exactly match your GitHub repository. Ensure you have a backup of any local modifications you wish to preserve that are NOT on GitHub before running this.

  4. Clean up any untracked files or directories (remnants from manual copying):
    Bash
    git clean -df
  5. Verify your repository status:

    Bash

    git status

    Expected Output:
    On branch main
    Your branch is up to date with 'origin/main'.

    nothing to commit, working tree clean

    After these final steps, your local plugin’s Git repository should be in a clean, synchronized state with GitHub, and your WordPress plugin should be able to perform Git operations without errors.