Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git clean does nothing

Tags:

git

git-clean

I am trying to clean my working tree, however, when I enter git clean --force nothing happens.

$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        packages/Microsoft.AspNet.WebPages.2.0.30506.0/
        packages/Microsoft.Data.Edm.5.2.0/
        packages/Microsoft.Data.OData.5.2.0/
        packages/Microsoft.Net.Http.2.0.20710.0/
        packages/Microsoft.Web.Infrastructure.1.0.0.0/

nothing added to commit but untracked files present (use "git add" to track)

$ git clean  --force

$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        packages/Microsoft.AspNet.WebPages.2.0.30506.0/
        packages/Microsoft.Data.Edm.5.2.0/
        packages/Microsoft.Data.OData.5.2.0/
        packages/Microsoft.Net.Http.2.0.20710.0/
        packages/Microsoft.Web.Infrastructure.1.0.0.0/

nothing added to commit but untracked files present (use "git add" to track)

Likewise, git clean -i has no effects either.

like image 437
BanksySan Avatar asked Nov 12 '14 20:11

BanksySan


People also ask

Why is git clean not removing untracked files?

Because the clean operation permanently deletes files, Git wants you to first run the command with the -n option to force a dry run. Remember that 'git clean' only removes untracked files. To find out if a file is tracked or not, developers can issue the 'git status' command from within the repository.

What does git clean does?

Summary. To recap, git clean is a convenience method for deleting untracked files in a repo's working directory. Untracked files are those that are in the repo's directory but have not yet been added to the repo's index with git add .

Does git clean delete files?

git clean deletes ignored files only if you use either the -x or -X option, otherwise it just deletes untracked files.


1 Answers

These are all directories, in order to remove directories you need to use the command :

git clean -f -d

Thanks to this answer.

like image 128
BanksySan Avatar answered Oct 08 '22 22:10

BanksySan