17

Possible Duplicate:
Git undo last commit

I have a folder structure like this..

~/git
     ......all repos of my github account
     .....play
     .....emacs.d
     .....dummy
     .....etc

i have created dummy repo to get familiar with git commands. so instead of initializing dummy folder,i have issued git init in git folder and issued git add . ,and committed to my local repo.

I want to go back to my previous state,and do not want to loose any changes i have done. How can i do that?

Community
  • 1
  • 1
  • You don't want to loose all your previous history in that repository or changes from the last commit you accidentally commited into it? Or both? – KL-7 Dec 28 '11 at 16:09

3 Answers3

7

I assume your ~/git folder was no git repo before? Simply delete the .git folder and everything is like it was before.

All repos (play, emacs.d etc) still have their individual .git folders and are complete repos..

The only thing you did was init another git repo that is now also tracking the other repositories (including their .git folder contents)

Tigraine
  • 23,358
  • 11
  • 65
  • 110
5

Just remove the .git folder in git, all the folders underneath will be fine.

Bashwork
  • 1,619
  • 8
  • 14
5

The repository will be in the .git directory. Delete that and this will no longer be a repository. You won't lose anything in the working copy.

Noufal Ibrahim
  • 71,383
  • 13
  • 135
  • 169