Should you commit .gitignore into the Git repos?

前端 未结 5 1341
天命终不由人
天命终不由人 2020-12-12 09:02

Do you think it is a good practice to commit .gitignore into a Git repo?

Some people don\'t like it, but I think it is good as you can track the file\'s history. Isn

5条回答
  •  生来不讨喜
    2020-12-12 09:25

    I put commit .gitignore, which is a courtesy to other who may build my project that the following files are derived and should be ignored.

    I usually do a hybrid. I like to make makefile generate the .gitignore file since the makefile will know all the files associated with the project -derived or otherwise. Then have a top level project .gitignore that you check in, which would ignore the generated .gitignore files created by the makefile for the various sub directories.

    So in my project, I might have a bin sub directory with all the built executables. Then, I'll have my makefile generate a .gitignore for that bin directory. And in the top directory .gitignore that lists bin/.gitignore. The top one is the one I check in.

提交回复
热议问题