1

I added and deleted some files after my last commit. I delted the whole subfolder accidentially. The order of git commands:

git add src/app/klicka/*

modified:   src/app/klicka/_klicka.scss
new file:   src/app/klicka/img/beispiel-buttons.png
new file:   src/app/klicka/img/beispiel-lightbox-1.png
new file:   src/app/klicka/img/beispiel-lightbox-2.png
new file:   src/app/klicka/img/beispiel-lightbox-3.png
new file:   src/app/klicka/img/beispiel-pascoe.png
new file:   src/app/klicka/img/button-jetzt-ausprobieren.png
new file:   src/app/klicka/img/referenzen-row-1.jpg
new file:   src/app/klicka/img/referenzen-row-2.jpg
new file:   src/app/klicka/img/referenzen-row-3.jpg

but there where still the deleted files

so I did:

git rm */klicka/* $(git ls-files --deleted)which I got from here: Removing multiple files from a Git repo that have already been deleted from disk but it seems you can't use it on a subpattern, so it removed my whole folder.

After that I used git reset because I wanted to unstage all changes. But now the folder is still gone. I did not commit is there a way to get back the status between the rm and the last commit? I still have other commits to do.

Community
  • 1
  • 1
Andi Giga
  • 3,744
  • 9
  • 38
  • 68
  • I tried this one: `git checkout HEAD path/to/file` is this the status of the last commit or the working tree status? The files are there but I' not sure what I did change. – Andi Giga Jun 12 '15 at 17:15
  • this may help: http://stackoverflow.com/a/19628406/17875 – Eevee Jun 13 '15 at 05:08

1 Answers1

0

You can use git reflog command, which gives HEAD list of commands execute by you. You can go back to the HEAD when you executed the command, everything will be back.

$ git reflog

Following will be the output

git reflog output

Now to go back to that HEAD, you can run below command suppose you want HEAD@{5} to be applied.

$ git reflog HEAD@{5}

You can get more info here http://git-scm.com/docs/git-reflog

Shreeram K
  • 1,719
  • 13
  • 22
  • this doesn't make sense; if the OP never committed, there is no other HEAD to go back to. – Eevee Jun 13 '15 at 05:07
  • but the question title says, to restore the files between last commit and current commit. – Shreeram K Jun 13 '15 at 05:10
  • and the first sentence of the question clarifies that it's the last commit that was made at all, not merely the previous commit – Eevee Jun 13 '15 at 18:14
  • Ok. But still a commit (last) was there which means he can go to that HEAD and he ll get the old folder that was deleted. And the new files he added can keep a copy and later on he can merge after getting the removed folder – Shreeram K Jun 13 '15 at 18:18