Deleted 2 months work with Git. How to get them back?

I don’t really know what I’ve just done so I’m just going to give a kind of timeline.

I was trying to set up a gitHub repository today for the first time. I have a folder where I keep all the files from my site and it had a .git folder. Every so often I was committing changes etc and everything seemed ok.

  • How many branches should I have ? How do I know it?
  • how to easily debug a symfony bundle shared across project
  • Manage python modules repeatedly updated in both local and original repository
  • Jenkins automatically commit artifacts
  • What are BASE, LOCAL, REMOTE and cppMerged files?
  • How to access to repository file with GIT in post-receive hook
  • Today I tried to merge two branches of the project I was working on. I tried “merge” and “rebase” commands but I couldn’t really understand what was happening or what I was doing so I decided I’d just start over with git.

    I pulled the .git folder out of my website folder (I didn’t delete it which I guess could be my saving grace here). Did a new git Init in the folder and committed the website files to it.

    That’s when I noticed loads of files were missing. I think they’re still in the first .git folder. Is there a way I can restore a directory from this folder?

  • Git pull request says “This branch has conflicts that must be resolved”
  • Does a Git branch you merged in from become part of the Git branch you merged to?
  • Does a Git a push configuration allow specifying the branch as well?
  • Can't find a decent git gui for windows. Anyone know of one?
  • When and why does Git update the modification time on .keep packfiles?
  • git, How to push local branch into the specific remote
  • One Solution collect form web for “Deleted 2 months work with Git. How to get them back?”

    I’m surprised that you’ve been working for two months with git and decided that starting over was that best way to recover from a failed rebase, it should be a lot easier.

    You should be able to recover your old commits into the new repository without too many problems.

    You can add a new remote that is your old saved repository:

    git remote add old /path/to/old/saved/.git
    

    Then you can fetch all of the old history.

    git fetch old
    

    Then you can open up a history browser (e.g. gitk --all) to have a look at the old history.

    You can check out versions of missing files with a command such as:

    git checkout old/master -- path/to/missing/file
    

    The old/master refers to the master branch in your old repository, you can use the id of any branch or commit here, though.

    Git Baby is a git and github fan, let's start git clone.