tags:

views:

109

answers:

1

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:

  1. Created new VS project and created a new git repository in it,
  2. Performed an initial scan, stage and commit but without adding a remote and performing a push,
  3. Worked on files for a week,
  4. (Today) Forgot to perform rescan, new stage and commit and just created new GitHub repository and performed this:

git remote add origin [email protected]:myaccount/webshop.git

git push origin master

  1. 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.

Help appreciated

+1  A: 

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.

Charles Bailey