• Git操作删除 untracked files


    最近使用git 管理项目的时候,编译过程中出现了很多中间文件,今天发现使用 git clean 命令可以很方便进行清除:

    # 删除 untracked files
    git clean -f
     
    # 连 untracked 的目录也一起删掉
    git clean -fd
     
    # 连 gitignore 的untrack 文件/目录也一起删掉 (慎用,一般这个是用来删掉编译出来的 .o之类的文件用的)
    git clean -xfd
     
    # 在用上述 git clean 前,墙裂建议加上 -n 参数来先看看会删掉哪些文件,防止重要文件被误删
    git clean -nxfd
    git clean -nf
    git clean -nfd
    NAME
           git-clean - Remove untracked files from the working tree
    
    SYNOPSIS
           git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>...
    
    DESCRIPTION
           Cleans the working tree by recursively removing files that are not under version control, starting from the current directory.
    
           Normally, only files unknown to Git are removed, but if the -x option is specified, ignored files are also removed. This can, for example, be useful to remove all build products.
    
           If any optional <path>... arguments are given, only those paths are affected.
    usage: git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <paths>...
    
        -q, --quiet           do not print names of files removed
        -n, --dry-run         dry run
        -f, --force           force
        -i, --interactive     interactive cleaning
        -d                    remove whole directories
        -e, --exclude <pattern>
                              add <pattern> to ignore rules
        -x                    remove ignored files, too
        -X                    remove only ignored files

    保持更新,转载请注明出处;更多内容请访问 cnblogs.com/xuyaowen 

  • 相关阅读:
    Linux系统开发笔记
    软件测试 | Chrome 浏览器+Postman还能这样做接口测试 ?
    yum 在线安装 nginx
    画图3D Paint 3D工作区黑屏
    InfluxDB 存储结构、读、写
    纯前端保存下载文件到本地
    umijs 配置的一些用法和解释 记录
    mongodb在双活(主备)机房的部署方案和切换方案设计
    mongodb oplog详解和格式分析
    麒麟操作系统上安装docker并加载镜像
  • 原文地址:https://www.cnblogs.com/xuyaowen/p/git-clean-untracked-files.html
Copyright © 2020-2023  润新知