Search code examples
gitcygwin

Unable to delete/remove .git folder from windows platform using git bash


I am using git bash shell on windows machine. Using git bash shell I was trying to remove/delete .git file, but unfortunately facing below error. After spending lots of hour I was unable to solve it. Please help !

enter image description here

Even run bash as an administrator. Very hefty issue now:

enter image description here

Updating details with the permissions:

prateek@PRATEEK-PC /E/Advance Java/Spring-Boot/example-spring-boot-mvc (master)
$ ls -ltra
total 15
drwxr-xr-x    1 prateek  Administ        0 Jul 17 22:23 src
-rw-r--r--    1 prateek  Administ      775 Jul 17 22:23 README.md
-rw-r--r--    1 prateek  Administ       20 Jul 17 22:23 .gitignore
drwxr-xr-x    1 prateek  Administ     4096 Jul 17 22:23 .git
drwxr-xr-x   11 prateek  Administ     4096 Jul 17 23:31 .settings
-rw-r--r--    1 prateek  Administ     1440 Jul 19 00:13 .project
drwxr-xr-x    1 prateek  Administ     4096 Jul 19 21:18 .
drwxr-xr-x   12 prateek  Administ     4096 Jul 19 21:18 target
-rw-r--r--    1 prateek  Administ     3304 Jul 19 21:32 pom.xml
-rw-r--r--    1 prateek  Administ     1308 Jul 19 21:32 .classpath
drwxr-xr-x    6 prateek  Administ     4096 Jul 19 21:41 ..

prateek@PRATEEK-PC /E/Advance Java/Spring-Boot/example-spring-boot-mvc (master)

Solution

  • Simply need to provide full permissions on the file and then you can delete it.

    user@user-PC /E/Advance Java/Spring-Boot/spring-boot-tutorials/example-spring-boot-mvc (master)
    $ ls -ltra
    total 9
    -rw-r--r--    1 prateek  Administ      775 Jul 17 22:23 README.md
    -rw-r--r--    1 prateek  Administ     3304 Jul 19 21:32 pom.xml
    drwxr-xr-x    4 prateek  Administ        0 Jul 19 22:20 src
    drwxr-xr-x    6 prateek  Administ     4096 Jul 19 22:21 .
    drwxr-xr-x    1 prateek  Administ     4096 Jul 19 22:22 .git
    drwxr-xr-x    8 prateek  Administ     4096 Jul 19 23:29 ..
    
    user@user-PC /E/Advance Java/Spring-Boot/spring-boot-tutorials/example-spring-boot-mvc (master)
    $ chmod 777 .git/
    
    user@user-PC /E/Advance Java/Spring-Boot/spring-boot-tutorials/example-spring-boot-mvc (master)
    $ rm -rf .git/
    
    user@user-PC /E/Advance Java/Spring-Boot/spring-boot-tutorials/example-spring-boot-mvc (master)
    $ ls -ltra
    total 7
    -rw-r--r--    1 prateek  Administ      775 Jul 17 22:23 README.md
    -rw-r--r--    1 prateek  Administ     3304 Jul 19 21:32 pom.xml
    drwxr-xr-x    4 prateek  Administ        0 Jul 19 22:20 src
    drwxr-xr-x    8 prateek  Administ     4096 Jul 19 23:29 ..
    drwxr-xr-x    5 prateek  Administ     4096 Jul 20 21:34 .