0

So I submitted a line on Git Bash "touch README.txt -m '...asdf ... qwer...' " attempting to create a readme file with text inside (I'm obviously new to this haha). The result was an empty README.txt file and a random file titled '...asdf ... qwer...' with filetype "file" that I can't get rid of. When I try to delete or alter it, a window pops up that says "Could not find this item. ... This is no longer located in [location]. Verify the location and try again." The Git GUI doesn't seem to recognize it either and I can't delete the parent directory. Command line deletion (del /r /q "...") was unsuccessful. Tried rebooting as well to see if it disappeared. It is not a hidden file.

What exactly happened here and how do I get rid of it? Thanks!

  • Possible duplicate of [Github README.md and readme.md - how to delete one?](https://stackoverflow.com/questions/12130498/github-readme-md-and-readme-md-how-to-delete-one) – Adya Apr 19 '18 at 02:07
  • Check this : https://stackoverflow.com/questions/12130498/github-readme-md-and-readme-md-how-to-delete-one – Adya Apr 19 '18 at 02:07
  • This sounds unrelated to Git at all; if I understand correctly you simply have an unstaged file which your OS has trouble handling ...? (Also your command will have created another file named `-m`.) Have you tried removing these with `rm`? If the command is still in your history, you should be able to replace `touch` with `rm` and have all three files disappear again. – tripleee Apr 19 '18 at 03:33
  • One way to put stuff in a new file is `echo foo bar >newfile` but creating a README file which doesn't contain anything useful isn't actually useful anyway. – tripleee Apr 19 '18 at 03:34
  • @tripleee, thanks for the comment. I did try removing the file with Git, but Git couldn't process it. Tried the command line (del /f /q ...) with no luck. And unfortunately it's no longer in my history. While it didn't let me move the file itself, I was able to move the parent directory with the file in it to another location on my hard drive that I won't really ever see much of. Just a band-aid, but it is what it is. Thanks for the echo tip. I'll try that next time. Cheers – yepnopesure Apr 19 '18 at 04:17
  • Try `rm ./-m ./*asdf*qwer*` – tripleee Apr 19 '18 at 04:20
  • And again, unless something is missing from the question, this doesn't seem to have anything at all to do with Git. The file is not in Git so of course you cannot remove it from Git. It's just a local file you created in your shell which Git knows nothing about. – tripleee Apr 19 '18 at 04:21
  • Yeah I suppose you're right as I never staged or committed it the file in Git. I thought it was relevant because I was working on pushing my website to GH when the file was created, but I guess it's a Bash issue? Fyi the -rm returned "no such file or directory" just like windows did when I tried deleting it. I've just accepted that I've tattoo'd this file into a deep corner of my hard drive at this point haha – yepnopesure Apr 19 '18 at 04:39
  • Why don't you just move other files elsewhere and delete the directory? – Varun Garg Apr 19 '18 at 06:29
  • @varungarg For whatever reason I'm unable to delete the directory. Can only move it, which I did to a deep dark corner of my hard drive where I won't have to see it. Copied the other files to a new folder and going resume from there. – yepnopesure Apr 19 '18 at 17:42
  • Its 2018 and Microsoft still has such issues, couldn't believe it – Varun Garg Apr 19 '18 at 17:46

1 Answers1

2

I had a similar issue trying to delete a file that "no longer existed" on my Windows 10 PC. What worked for me was adding the problem file(s) to an archive and ensuring the option, "Delete files after compression" (or equivalent option) in the archive software was ticked. Once the archive process completed, the problem file disappeared from the folder. I then deleted the archive file and everything was good to go.

To add the file to an archive make sure you have something like 7-Zip or WinRAR installed. Here's an example using 7-Zip:

  1. Right-click the problem file and select "7-Zip" from the context menu followed by the "Add to archive" option.

  2. In the "Add to Archive" dialogue, tick the "Delete files after compression" option.

  3. Select the OK button.

The problem file will disappear and an archive file will appear in your folder in its place (hopefully!).

  1. Delete the archive file.

Hope this works for you too.

humbleHacker
  • 437
  • 6
  • 17