每次配置git的时候,要写gitignore文件,你知道你的.gitignore匹配那些文件吗?


  • 看看.gitignore放过了哪些文件:

     

    git ls-files -ocm --exclude-standard
    git status -u
    

    这个命令显示了将会被git管理的文件

  • 看看.gitignore命中的文件:
      $ (git ls-files -oi --exclude-standard; git ls-files -oi --exclude-standard --directory) | sort | uniq
      $ (git ls-files -oi --exclude-standard; git ls-files -oi --exclude-standard --directory) | perl -nle '$seen{$_}++||next;if(-d){system"find",$_,"-type","f"}else{print}'
      $ git clean -ndX
    

    这个命令显示了被.gitignore匹配,然后不被git管理的文件

  • To list both together:
      $ (git ls-files -ocm --exclude-standard | perl -ple 's/^/+ /'; (git ls-files -oi --exclude-standard; git ls-files -oi --exclude-standard --directory) | perl -nle '$seen{$_}++||next;if(-d){system"find",$_,"-type","f"}else{print}' | perl -ple 's/^/- /') | sort
    

built-in


  • 添加文件,然后提交

     

    git add -n
    git commit --dry-run
    

如果你觉得写得不错,请捐赠作者:

作者:

相关文章:

  • 2021-11-06
  • 2021-07-05
  • 2021-08-06
  • 2021-12-07
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
  • 2021-07-09
猜你喜欢
  • 2022-12-23
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2022-02-01
  • 2022-01-31
  • 2022-01-01
相关资源
相似解决方案