Git deleted all my files

I just ran git clean -df in my home directory and all of my files were removed. Could anyone explain this problem? I think I accidentally committed my home directory a couple years back and this caused it to roll back to a later version? But how would I of committed it if there was no place to push it to.

Update: I found out that I created the project in the home directory.

  • calculating a git packfile sha1 checksum in java
  • Getting grunt.js to work on a pre-existing yeoman project
  • Is it possible to push my code from my server to Github?
  • Can any source control system handle branching code base on a per client basis?
  • Git fetch and merge skipped asking me for conflicts
  • How do I push to a pull request on github?
  • ONLY Build the latest commit in buildbot
  • Git push commits from another repo without the original user info
  • Merge two git repository by applying one ontop of another
  • How include 3rd party jars in maven project (compile, build, package) where adding local maven repo is not an option?
  • git clone requires ssh:// protocol when perhaps it shouldn't?
  • Open a file directly from a GitLab private repository
  • 2 Solutions collect form web for “Git deleted all my files”

    … caused it to roll back to a later version?

    That’s not what git clean does. It simply removes any files that aren’t currently tracked by Git. It does not change tracked files which contain modifications.

    But how would I of committed it if there was no place to push it to.

    That has nothing to do with how Git works. You do not need to push anything anywhere in order to initialize a repo and begin committing things to it.

    If you initialize a repository in a directory that has files, that’s fine. Now your repository has 0 tracked files, and every file that was already present is an untracked file.

    You then told Git to delete all untracked files, and confirmed that you did indeed want Git to do this destructive action with the -f flag. To make it worse, you used -d to tell Git to recursively descend into directories and delete any untracked files it finds there too.

    See the documentation for git clean

    -d
    Remove untracked directories in addition to untracked files. If an untracked directory is managed by a different Git repository, it is not removed by default. Use -f option twice if you really want to remove such a directory.

    -f
    –force
    If the Git configuration variable clean.requireForce is not set to false, git clean will refuse to run unless given -f, -n or -i.

    Basically you told git to remove all files in the current directory that it didn’t know about

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