Should you commit .gitignore into the Git repos?

前端 未结 5 1347
天命终不由人
天命终不由人 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:44

    Committing .gitignore can be very useful but you want to make sure you don't modify it too much thereafter especially if you regularly switch between branches. If you do you might get cases where files are ignored in a branch and not in the other, forcing you to go manually delete or rename files in your work directory because a checkout failed as it would overwrite a non-tracked file.

    Therefore yes, do commit your .gitignore, but not before you are reasonably sure it won't change that much thereafter.

提交回复
热议问题