Is there a way to tell git to only include certain files instead of ignoring certain files?

前端 未结 5 1671
感情败类
感情败类 2020-12-12 09:16

My programs generally generate huge output files (~1 GB) which I do not want to be backing up to the git repository. So instead of being able to do

git add          


        
5条回答
  •  無奈伤痛
    2020-12-12 10:04

    The best solution to achieve this

    create .gitignore file in repository root, and if you want to include only .c file then you need to add below lines to .gitignore file

    *.*
    !*.c
    

    this will include all .c file from directory and subdirectory recursively.

    using

    *
    !*.c
    

    will not work on all version of git.

    Tested on

    git version 2.12.2.windows.2

提交回复
热议问题