Restore original file which was deleted during patch creation

I have just started using git. For some reason I have to create a patch of my changes which inclueds (file modification + 4 new files creation). I am successfully able to cretae a patch. But during this process some how those files which I have created got deleted. I want those files again. How can I get that.

  • One product ( server side / client side 1 / client side 2… ) in one repository git
  • How to visit a private host behind a router?
  • How to find git log messages with more than one line?
  • Installing Git on a Debian Lenny server
  • Git clone error in Xcode
  • TFS Git create repo - “User must become compliant”
  • Merge separate git repositories into one repository, organized by folders
  • How do I enable cloning over SSH for a Gitlab runner?
  • 2 Solutions collect form web for “Restore original file which was deleted during patch creation”

    If those files were committed, a simple

    git checkout -
    # or
    git checkout -f HEAD
    

    should be enough to checkout again the content of the working directory (but it can override any current – not-yet-committed – work), so be careful (a git stash could be useful first).

    Do you need to use patches? Assuming where you are sending them, they are using git as well, you can just send them a git bundle. Take a look at the git bundle command here: http://www.kernel.org/pub/software/scm/git/docs/git-bundle.html

    If you generated the patches for the new files by taking the output of git diff, you won’t be able to issue any git commands to get them back as they were never part of anything that git tracked. Simply recreate the files by cutting out the contents of the patches you made.

    If you generated the patches for the new files after having committed them to history you can get back to the original state of that latest commit by any one of these methods:

    git stash 
    git checkout -- .
    git reset --hard
    

    be careful that you don’t have existing work when doing this. Stash is the safest one of all those commands as it stores the state of your modifications in a reference in history. In case you zapped something, you can get it back with stash pop

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