Skip to content

Instantly share code, notes, and snippets.

@AudreyLin
Last active March 2, 2022 09:41
Show Gist options
  • Save AudreyLin/a3b7a82d99f1b251d67eba318c53efe1 to your computer and use it in GitHub Desktop.
Save AudreyLin/a3b7a82d99f1b251d67eba318c53efe1 to your computer and use it in GitHub Desktop.
Remove .git file from your directory with git bash terminal

Deleting .git from directory in git bash/linux terminal

Purpose

Forcefully Remove files within a directory, overriding the up-to-date check.

Warning

Be careful not to delete anything important. This is permanent. The -rf portion forcefully removes the file without prompting for confirmation. See the resources below for more information.

Example

Create-React-App always includes their .git and .gitignore files in the download. I create my own, so I like to delete the ones downloaded with create-react-app.

(I always forget how to do this, so I'm just making this gist to remind myself & anyone else who wants to use it.)

  1. In your linux/bash terminal cd into your directory
  2. rm -rf <file> (in this case: rm -rf .git)
  3. Enter

Viola! You've just forcefully deleted the .git file from your directory.

Resources

git-rm flag docs

rm -rf commands in linux

Chen Hui Jing Blog Post with more info about these commands

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment