Github: 上传包含30个子文件夹的文件夹时,我可以只创建一个gitignore吗?

Github: when uploading a folder containing 30 subfolders, can I create just one gitignore?

我是 Github 的新手,只想了解如何最有效地上传我的项目,因为我一次要上传的项目太多了。我有三十个项目,我知道我可以:

"upload the entire folder containing all your projects and have a web page link to each of the subfolders seperately whilst keeping them all contained in one repository."

然而,这是否意味着我可以为所有项目创建一个 gitignore,或者我仍然需要为每个单独的子文件夹创建一个 gitignore?有没有办法只创建一个?

您可以按照 the docs:

中的说明在您的机器上创建一个全局 gitignore

Create a global .gitignore

You can also create a global .gitignore file, which is a list of rules for ignoring files in every Git repository on your computer. For example, you might create the file at ~/.gitignore_global and add some rules to it.

Open Terminal. Run the following command in your terminal:

git config --global core.excludesfile ~/.gitignore_global

注意 这是 客户端 机器特定的,所以每个检查你的 repo 的人都需要这个设置。服务器从不 "ignores" 文件,因为每个 repo 都是独立的。