Varsayalım ki git add --all komutunun "untracked" dosya ve klasörleri etkilemesini istemiyorsunuz, bu nedenle onlari çalışma klasöründen fiziksel olarak kaldırmak istiyorsunuz. Bu işlem için git clean -fd komutu kullanılır. Bu komuttan geri dönüş olmadığını hatırlamak gerekiyor. Muhtemel hasarı görmek için -n veya --dry-run parametreleri kullanılır. Daha fazla bilgi için git clean linkini tıklayın.


Mevcut durumu kontrol edelim


inanzzz@inanzzz:~/project$ git status
On branch my-feature-branch
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: file_two.txt

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: file_one.txt

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

dir_one/
file_six.txt

Sadece dosyaları kaldır


Aşağıda göründüğü gibi "file_six.txt" listeden kaldırıldı.


inanzzz@inanzzz:~/project$ git clean -f
Removing file_six.txt
inanzzz@inanzzz:~/project$ git status
On branch my-feature-branch
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: file_two.txt

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: file_one.txt

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

dir_one/

Mevcut durumu kontrol edelim


inanzzz@inanzzz:~/project$ git status
On branch my-feature-branch
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: file_two.txt

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: file_one.txt

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

dir_one/
file_seven.txt

Dosya ve klasörleri kaldır


Aşağıda göründüğü gibi "file_seven.txt" ve "dir_one/" listeden kaldırıldı.


inanzzz@inanzzz:~/project$ git clean -fd
Removing dir_one/
Removing file_seven.txt
inanzzz@inanzzz:~/project$ git status
On branch my-feature-branch
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: file_two.txt

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: file_one.txt