Layla
Layla

Reputation: 357

Git Failing to remove with clean

when I type in git clean -f i get the following error message:

>     Removing .__afs043
>     warning: failed to remove .__afs043
>     Removing .__afs0F7D
>     warning: failed to remove .__afs0F7D
>     Removing .__afs1359
>     warning: failed to remove .__afs1359
>     Removing .__afs1421
>     warning: failed to remove .__afs1421
>     Removing .__afs243A
>     warning: failed to remove .__afs243A
>     Removing .__afs2745
>     warning: failed to remove .__afs2745
>     Removing .__afs3454
>     warning: failed to remove .__afs3454
>     Removing .__afs3D12
>     warning: failed to remove .__afs3D12
>     Removing .__afs4A5E
>     warning: failed to remove .__afs4A5E
>     Removing .__afs4FB8
>     warning: failed to remove .__afs4FB8
>     Removing .__afs5D5B
>     warning: failed to remove .__afs5D5B
>     Removing .__afs5E1D
>     warning: failed to remove .__afs5E1D
>     Removing .__afs6086
>     warning: failed to remove .__afs6086
>     Removing .__afs6328
>     warning: failed to remove .__afs6328
>     Removing .__afs6D97
>     warning: failed to remove .__afs6D97
>     Removing .__afs7562
>     warning: failed to remove .__afs7562
>     Removing .__afs7C22
>     warning: failed to remove .__afs7C22
>     Removing .__afs8148
>     warning: failed to remove .__afs8148
>     Removing .__afs865F
>     warning: failed to remove .__afs865F
>     Removing .__afs8CE5
>     warning: failed to remove .__afs8CE5
>     Removing .__afs9295
>     warning: failed to remove .__afs9295
>     Removing .__afs938C
>     warning: failed to remove .__afs938C
>     Removing .__afs9439
>     warning: failed to remove .__afs9439
>     Removing .__afsA5EC
>     warning: failed to remove .__afsA5EC
>     Removing .__afsA859
>     warning: failed to remove .__afsA859
>     Removing .__afsB044
>     warning: failed to remove .__afsB044
>     Removing .__afsB9EF
>     warning: failed to remove .__afsB9EF
>     Removing .__afsC47E
>     warning: failed to remove .__afsC47E
>     Removing .__afsCF6E
>     warning: failed to remove .__afsCF6E
>     Removing .__afsD42
>     warning: failed to remove .__afsD42
>     Removing .__afsD50F
>     warning: failed to remove .__afsD50F
>     Removing .__afsE6B9
>     warning: failed to remove .__afsE6B9
>     Removing .__afsE9F3
>     warning: failed to remove .__afsE9F3
>     Removing .__afsF0DA
>     warning: failed to remove .__afsF0DA
>     Removing .__afsF9EA
>     warning: failed to remove .__afsF9EA

from the command. Yet i need to remove these files in order to checkout of my branch because I get the following message:

Error: The following untracked working tree files would be overwritten
by checkout:
          .__afs4FB8
          .__afs6D97
          .__afs865F
          .__afs9439
          .__afsF9EA Please move or remove them before you can switch branches. 

Aborting

What do I do??! I need to be able to checkout and update this branch fast!

Upvotes: 12

Views: 24855

Answers (4)

Elijah Lynn
Elijah Lynn

Reputation: 13468

You need to check permissions on the files AND the containing folder. If the files have write permission then the folder most likely does not.

chmod u+w . while inside the folder. Then git clean --force -d should work.

-d
Normally, when no <path> is specified, git clean will not recurse into untracked directories to avoid removing too much. Specify -d to have it recurse into such directories as well...

source: git help clean Blockquote

Upvotes: 3

Qwerty
Qwerty

Reputation: 31915

Try sudo git clean -f. You probably need elevated rights.

Upvotes: 10

rainecc
rainecc

Reputation: 1502

  • go to another (empty) folder
  • run git init .
  • checkout your branch there

Upvotes: 2

krzysz00
krzysz00

Reputation: 2103

Since git clean is refusing to remove these untracked files, try removing them manually by doing

rm -f ._afs4FB8 ._afs6D97 ._afs865F ._afs9439 .__afsF9E

This should either remove the files or give you a more helpful error message.

Upvotes: 5

Related Questions