Workflow error working directory has unstaged changes

Viewed 277

Whenever I am trying to push/merge changes, a workflow in GitHub is getting failed and displays an error that "Working directory has unstaged changes"; After committing, it's asking me to push changes; After pushing I receive an error notification on github site;


error notification, more info can be seen by clicking on x sign


Below is the code in workflow .github/workflows/dev-deploy.yml .

      chmod 600 ~/.ssh/*
      git config --local core.sshCommand 'ssh -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes -o StrictHostKeyChecking=no'
      git remote add DEV "$DEV_REPO"
      git push DEV

Below is the output accessible after either clicking email saying "DEV Deploy: All jobs have failed". it actually executes a workflow, or after clicking on GitHub site notification, it takes us to the workflow. if we click on build it says "Working directory has unstaged changes",


workflow build error details


so far I've tried before git push DEV;

rm -r *
git reset --hard
git read-tree --reset -u HEAD
git restore -- .

But nothing seems to be working, it'd be great if someone can help me.

1 Answers

You could try a:

git read-tree --reset -u HEAD

To make sure unmerged entries are discarded.

Or:

git restore -- .

Update July 2022:

The GitHub Action checkout includes an interesting test __test__/verify-no-unstaged-changes.sh with the message:

    echo "::error::Unstaged changes detected. 
         Locally try running: git clean -ffdx && npm ci && ..."

So you can try a git clean -ffdx and see if that is enough in your case.

Related