Search code examples
gitgit-init

How can I fully delete a Git repository created with init?


I created a Git repository with git init. I'd like to delete it entirely and initialise a new one.


Solution

  • Git keeps all of its files in the .git directory. Just remove that one and initialise again.

    If you can't find it, it's because it is hidden.

    • In Windows 7, you need to go to your folder, click on Organize on the top left, then click on Folder and search options, then click on the View tab and click on the Show hidden files, folders and drives radio button.

    • On a Mac OS X:

      • Open a Terminal instance (via Spotlight: press CMD + SPACE, type terminal and press Enter) and run:

          defaults write com.apple.finder AppleShowAllFiles 1 && killall Finder
        

      Note: The keyboard shortcut to show hidden files in Finder is CMD + SHIFT + ., so it isn't necessary any longer to modify the Finder configuration this way

      • You could also type cd (the space is important), drag and drop your Git repository folder from Finder to the terminal window, press return, type rm -fr .git, and then return again.
    • On Ubuntu (Linux), use shortcut Ctrl + H.