git destroyed my changes
I made a commit of my repository a week ago but never actually pushed it to the remote at github, which I did today. However, in the time from my commit I made many changes to the source. But just the initial commit was pushed to remote and while doing it, it also overwrote my local files.
What can I do to get back my current files??
For better understanding, this is what I’ve done:
- Created new VS project and created a new git repository in it,
- Performed an initial scan, stage and commit but without adding a remote and performing a push,
- Worked on files for a week,
- (Today) Forgot to perform rescan, new stage and commit and just created new GitHub repository and performed this:
git remote add origin email@example.com:myaccount/webshop.git
git push origin master
- Now the files in GitHub repository are the ones from inital commit and those were also copied over my current files, so I’m in the initial commit stage now locally too, which is awful.
One Solution collect form web for “git destroyed my changes”
It appears that you accidentally stashed your changes.
This command lists any stashes that you have made.
git stash list
git will only apply a stash if you don’t have any unstaged changes in your working tree, so to apply the changes you can stage any unstaged changes with this command.
git add -u
Then you can apply the stash with this command.
git stash apply
git may prompt you to resolve any conflicts if you are applying onto a file which has changed since you made the stash.