branch - How to remove local (untracked) files from the current Git working tree? -


how delete untracked local files current working tree?

as per git documentation git clean

remove untracked files working tree


step 1 show deleted using -n option:

git clean -n 

clean step - beware: delete files:

git clean -f 
  • to remove directories, run git clean -f -d or git clean -fd
  • to remove ignored files, run git clean -f -x or git clean -fx
  • to remove ignored , non-ignored files, run git clean -f -x or git clean -fx

note case difference on x 2 latter commands.

if clean.requireforce set "true" (the default) in configuration, 1 needs specify -f otherwise nothing happen.

again see git-clean docs more information.

options

-f

--force

if git configuration variable clean.requireforce not set false, git clean refuse run unless given -f, -n or -i.

-x

don’t use standard ignore rules read .gitignore (per directory) , $git_dir/info/exclude, still use ignore rules given -e options. allows removing untracked files, including build products. can used (possibly in conjunction git reset) create pristine working directory test clean build.

-x

remove files ignored git. may useful rebuild scratch, keep manually created files.

-n

--dry-run

don’t remove anything, show done.

-d

remove untracked directories in addition untracked files. if untracked directory managed different git repository, not removed default. use -f option twice if want remove such directory.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -