I have done about 2 months work locally against main branch (without committing or staging anything). This included adding new (untracked) files and modifying existing tracked files.
Then I wanted to check something on the main branch without my changes so did:
git stash -all
Expecting it to stash both my tracked and untracked file changes.
I then did
git stash pop
To get my changes back, and got thousands of errors:
.project already exists, no checkout
all/.project already exists, no checkout
all/.settings/org.eclipse.wst.common.component already exists, no checkout
all/target/vault-work/META-INF/MANIFEST.MF already exists, no checkout
all/target/vault-work/META-INF/vault/config.xml already exists, no checkout
all/target/vault-work/META-INF/vault/filter.xml already exists, no checkout
all/target/vault-work/META-INF/vault/properties.xml already exists, no checkout
all/target/vault-work/META-INF/vault/settings.xml already exists, no checkout
core/.project already exists, no checkout
core/target/classes/META-INF/MANIFEST.MF already exists, no checkout
core/target/classes/OSGI-INF/com.xx.aem.core.filters.CorrelationLoggingFilter.xml already exists, no checkout
core/target/classes/OSGI-INF/com.xx.aem.core.filters.LinkHeaderFilter.xml already exists, no checkout
core/target/classes/OSGI-INF/com.xx.aem.core.filters.LoggingFilter.xml already exists, no checkout
and ending in:
ui.content/target/vault-work/META-INF/vault/settings.xml already exists, no checkout
ui.frontend/.project already exists, no checkout
ui.tests/.project already exists, no checkout
error: could not restore untracked files from stash
The stash entry is kept in case you need it again.
Surprisingly, when looking at the state of the local code, it does seem to have created the new files. But none of the changed files are there. So the error says it could not restore untracked files, but it appears to have, but it has not recovered the changes I made to existing files.
Summary:
- I had changed files and new (untracked files) from main.
- I did "git stash -all"
- This got me back to main without my changes.
- I then did "git pop", expecting to be back to 1.
- got thousands of errors for no apparent reason.
- None of my changes to files are there.
- My new, untrack files do see to be there, despite it saying it could not restore them.
How do I get back all the changes I did to existing files?
Any help appreciated.
Note: I have recently noticed that git stash --all (which was recommended on a post in order to stash tracked and untracked files) may also (bizarrely) stash ignored files - this could be the crux of the problem.
If I do
git stash show
I get
bob@MacBook-Pro eyas-web % git stash show
.../aem/core/filters/xx.java | 25 ++-
.../models/xxx/response/x.java | 18 --
.../xx/aem/core/models/xx/Player.java | 14 ++
.../xx/aem/core/services/xx.java | 31 +++
.../services/impl/xx.java | 2 +-
.../core/services/impl/xx.java | 6 +
.../aem/core/services/impl/xx.java | 212 ++++++++++++++++++++-
pom.xml | 18 --
8 files changed, 282 insertions(+), 44 deletions(-)
I need to figure out how to get the "8 files changed" back from the stash, along side the new untracked files which do seem to have been restored.
One idea might be to try to remove all the ignored files, then do git stash pop again. However, looking at the man pages for "git clean -xdf", it doesn't say if -x also removes the necessary git files as well as the ignored files we added (such as project config files).
Any ideas how to fix this?
I noticed this post: How do you stash an untracked file?
Which says: "git stash -u Warning, doing this will permanently delete your files if you have any directory/ entries in your gitignore file."
This seems very bad, and may be related to my issue.