Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Git: `stash` does not find local changes but `pull` finds them

I am trying to automate deployment of my project using Github Actions. The workflow is something like this:

    git stash
    git stash drop
    git pull
    # install dependencies and ...

When first two lines are executed, git cannot find any local change:

    out: No local changes to save
    err: No stash entries found.

But then after git pull runs, this happens:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    err: From https://github.com/*****/*****
    err:  * branch            main       -> FETCH_HEAD
    err:  ****..****          main       -> origin/main
    err: error: The following untracked working tree files would be overwritten by merge:
    err:    thefile
    err: Please move or remove them before you merge.
    err: Aborting

Why is it happening?

>Solution :

Your changes are untracked. By default, git stash includes only tracked files.

If you want the changes to be stashed, you need either of the following:

  • modify command to include untracked files: git stash --include-untracked
  • make files tracked using git-add, e.g. to track all files: git add *
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading