stefanzweifel / git-auto-commit-action

Automatically commit and push changed files back to GitHub with this GitHub Action for the 80% use case.
MIT License
2.02k stars 229 forks source link

Error: Please commit your changes or stash them before you switch branches. #158

Closed nachg closed 3 years ago

nachg commented 3 years ago

If there are some changes in a previously added file, such error will be thrown:

  > Switching/creating branch...
  Error: Error: error: Your local changes to the following files would be overwritten by checkout:
    .github/badges/jacoco.svg
  Please commit your changes or stash them before you switch branches.
  Aborting

Steps to reproduce: 1) Add a step to the job that will generate some file with dynamic content 2) Add add-and-commit@ action after the previous step 3) Run Job more than one time

Actual result: message from above Expected results: changed files should be committed.

Logs: logs_54.zip

stefanzweifel commented 3 years ago

This sound similar to this previous issue: https://github.com/stefanzweifel/git-auto-commit-action/issues/155

git-auto-commit will not resolve such complex git issues for you. If this is something that regularly can happen in your workflows, make sure to write your workflow so that such issues resolve themselves.

From your comment and the zipped log I assume that you have a lengthy workflow which does some stuff and at the end you switch branches and want to to commit those files.

Maybe you can try switching to a new branch earlier or stashing and unstashing the files on your own?

nachg commented 3 years ago

I agree. Sorry for Disturbing you. This is not a problem of this project.

stefanzweifel commented 3 years ago

No problem! Always happy to help or clarify things.