Skip to content

Commit 395abfd

Browse files
committed
Merge pull request #24 from anchal20/master
Using clean to forcefully remove files/directory
2 parents cab6261 + f7ac6d2 commit 395abfd

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
* [Show all ignored files](https://github.com/git-tips/tips#show-all-ignored-files)
4545
* [Create new working tree from a repository (git 2.5)](https://github.com/git-tips/tips#create-new-working-tree-from-a-repository-git-25)
4646
* [Create new working tree from HEAD state](https://github.com/git-tips/tips#create-new-working-tree-from-head-state)
47+
* [Before deleting untracked files/directory, do a dry run to get the list of these files/directories](https://github.com/git-tips/tips#before-deleting-untracked-filesdirectory-do-a-dry-run-to-get-the-list-of-these-filesdirectories)
48+
* [Forcefully remove untracked files](https://github.com/git-tips/tips#forcefully-remove-untracked-files)
49+
* [Forcefully remove untracked directory](https://github.com/git-tips/tips#forcefully-remove-untracked-directory)
4750

4851
<!-- Don’t remove or change the comment below – that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
4952
<!-- @doxie.inject end toc -->
@@ -299,5 +302,26 @@ git worktree add -b <branch-name> <path> <start-point>
299302
git worktree add --detach <path> HEAD
300303
```
301304

305+
## Before deleting untracked files/directory, do a dry run to get the list of these files/directories
306+
```sh
307+
git clean -n
308+
```
309+
310+
## Forcefully remove untracked files
311+
```sh
312+
git clean -f
313+
```
314+
315+
## Forcefully remove untracked directory
316+
```sh
317+
git clean -f -d
318+
```
319+
320+
321+
__Alternatives:__
322+
```sh
323+
git clean -df
324+
```
325+
302326
<!-- Don’t remove or change the comment below – that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
303327
<!-- @doxie.inject end -->

tips.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,18 @@
169169
{
170170
"title": "Create new working tree from HEAD state",
171171
"tip": "git worktree add --detach <path> HEAD"
172+
},
173+
{
174+
"title": "Before deleting untracked files/directory, do a dry run to get the list of these files/directories",
175+
"tip": "git clean -n"
176+
},
177+
{
178+
"title": "Forcefully remove untracked files",
179+
"tip": "git clean -f"
180+
},
181+
{
182+
"title": "Forcefully remove untracked directory",
183+
"tip": "git clean -f -d",
184+
"alternatives": ["git clean -df"]
172185
}
173186
]

0 commit comments

Comments
 (0)