LoginSignup
0
0

More than 1 year has passed since last update.

[Git] 動作を試す 実行例25:cleanで管理していないファイルを削除する

Posted at

Gitの動作を理解するために、Gitのコマンドを実際に試して、結果を見てみました。

1つの記事内で一連のGitコマンドが完結しているので、これら一連のコマンドを順に実行させて結果を見ることで、一連のGitの動作を実際に体感でき、一通り独習することが可能です。

※前回記事のリポジトリ状態からの続きになっています。

前回記事へ 目次へ:Git関連記事のまとめページ 次回記事へ

実行例

untracked fileを削除するためにはgit cleanを使う - Qiita
https://qiita.com/tmyn470/items/c8359e4ec92d1f462bdf

引用:
削除する前に、削除の対象となるファイルを確認
git clean -n
git clean -dn
untracked fileを削除(ディレクトリを削除する場合はd)
git clean -f
git clean -df

(※ひとまず適当にファイルを作成)
echo Sample-Added-11 > test101.txt
mkdir test102
echo Sample-Added-11 > test102/test102.txt
dir /b
↓
結果: 
test1.txt
test101.txt
test102
test2.txt
test4.txt

-----

git clean -n
↓
結果: 
Would remove test101.txt

git clean -dn
↓
結果: 
Would remove test101.txt
Would remove test102/

dir /b
↓
結果: 
test1.txt
test101.txt
test102
test2.txt
test4.txt

-----

git clean -f
↓
結果: 
Removing test101.txt

dir /b
↓
結果: 
test1.txt
test102
test2.txt
test4.txt

git clean -df
↓
結果: 
Removing test102/

dir /b
↓
結果: 
test1.txt
test2.txt
test4.txt

環境

Windows 10、PortableGit-2.40.0-64-bitを使用、全てローカルPC上で実施、GitHub等は不使用。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0