Git删除untracked file的方法-交互式

Git删除untracked file的方法

2019年4月29日 / 584次阅读
Git

有的时候,我们会不小心因为写错文件名,或者一些别的原因,在Git仓库中,产生了一些untracked file,有一些untracked file可以通过.gitignore文件来使其隐身,有一些可以通过本文介绍的方法来删除。

xinlin@ubuntu:~/gas$ touch kkk
xinlin@ubuntu:~/gas$ touch aaa
xinlin@ubuntu:~/gas$ touch bbb
xinlin@ubuntu:~/gas$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: README.md

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: gas.py

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

aaa
bbb
kkk

随便建了3个没用的文件,现在我们来删除:

xinlin@ubuntu:~/gas$ git clean -i
Would remove the following items:
aaa bbb kkk
*** Commands ***
1: clean 2: filter by pattern 3: select by numbers
4: ask each 5: quit 6: help
What now> 3
1: aaa 2: bbb 3: kkk
Select items to delete>> 2
1: aaa * 2: bbb 3: kkk
Select items to delete>>
Would remove the following item:
bbb
*** Commands ***
1: clean 2: filter by pattern 3: select by numbers
4: ask each 5: quit 6: help
What now> c
Removing bbb

用-i这个参数比较安全,以交互式的方式,清晰的告诉你哪些文件会被删除。git clean还有其它参数,参考git help clean。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值