git remove folder code example

Example 1: delete .git folder

rm -rf .git

Example 2: git remove folder remotely

git rm -r --cached <folder>
git commit -m "Removed Folder"
git push origin master

Example 3: remove folders from remote git

git rm -r --cached FolderName
git commit -m "Removed folder from repository"
git push origin master

Example 4: how to remove git from a folder

rm -rf .git

Example 5: git remove folder from repository

# the -r option will recursively delete the folder
git rm -r folder-name
# commit changes
git commit -m "Remove duplicated directory"

Example 6: remove folders from remote git

git rm -r one-of-the-directories // This deletes from filesystem
git commit . -m "Remove duplicated directory"
git push origin <your-git-branch> (typically 'master', but not always)