'How to delete a file using git command line interface when it says permission denied on deleting?

I am learning git from a youtube tutorial, I am unable to delete a file. When I am giving this command, where names.txt is file name, I see this:

$ rm -rf names.txt
rm: cannot remove 'names.txt': Permission denied"
samiksha@Kitty MINGW64 ~/Desktop/gitt (master)
$ git add .
warning: LF will be replaced by CRLF in names.txt.
The file will have its original line endings in your working directory

samiksha@Kitty MINGW64 ~/Desktop/gitt (master)
$ git commit -m "adding new files"
[master f1f061e] adding new files
 1 file changed, 12 insertions(+)

samiksha@Kitty MINGW64 ~/Desktop/gitt (master)
$ git log
commit f1f061eafb856a25ae5521482cee25f5e7ff1aeb (HEAD -> master)
Author: Mi-kio <[email protected]>
Date:   Fri Feb 18 14:59:04 2022 +0530


    adding new files

commit bc5b891ef1476ecfbbde57d1f96063c75f58b0c8
Author: Mi-kio <[email protected]>
Date:   Fri Feb 18 14:41:05 2022 +0530

    adding files

samiksha@Kitty MINGW64 ~/Desktop/gitt (master)
$ rm -rf names.txt
rm: cannot remove 'names.txt': Permission denied

The content of my names.txt is

akshi 
SAmiksha
Navanshi 
ANshuka
mansi
shuchi
anvi anaya


I am not able to delete it or any other file also in which I have not added any content.



Solution 1:[1]

Run this on the gitt (master) directory:

samiksha@Kitty$ chmod 777 gitt

Then you can run the

$ rm -rf names.txt

This should give you the permission to modify any file in the whole directory.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 antzshrek