如何将忽略的文件上传到 github 存储库
How to upload ignored files to github repository
在我的本地存储库中,我有 8 个文件
但是我已经指定忽略 .gitignore
中的 .mat
个文件。因此,在 github 上推送存储库时,不会添加忽略的文件。
但我希望以后克隆我的存储库的任何人都拥有 .mat
文件和照片作为与该程序一起使用的数据示例。
我可以上传文件,但这样以后克隆存储库的用户将不会在克隆时下载这些文件。
我还可以修改 .gitignore
文件并提交添加 .mat
文件以将它们包含在我的 github 存储库中。
但是还有别的办法吗?
But in I have specified to ignore .mat files in .gitignore. So when pushing the repository on github, the ignored files are not added.
没有添加被忽略的文件,因为您没有添加它们:) 不是因为 .gitignore
.
I can upload the files but that way the user who clone the repository later won't download those files when cloning.
这是错误的。如果这些文件在存储库中,它们将被克隆。因此,一种方法是 git add --force
() 他们并提交。
.gitignore
会在 运行 git status
时更改 "Untracked files" 的输出 - 如果存在文件或文件类型,则它不会显示在 "Untracked files" 列表。但是您仍然可以添加并提交它。
如果您希望任何 .mat
文件从现在起 显示在 "Untracked files" 列表中,您只应修改 .gitignore
。但是,如果您只想将一些特定的添加到您的存储库中,仅此而已,那么您不应该修改它。
有关详细信息,请参阅 gitignore documentation。
在我的本地存储库中,我有 8 个文件
但是我已经指定忽略 .gitignore
中的 .mat
个文件。因此,在 github 上推送存储库时,不会添加忽略的文件。
但我希望以后克隆我的存储库的任何人都拥有 .mat
文件和照片作为与该程序一起使用的数据示例。
我可以上传文件,但这样以后克隆存储库的用户将不会在克隆时下载这些文件。
我还可以修改 .gitignore
文件并提交添加 .mat
文件以将它们包含在我的 github 存储库中。
但是还有别的办法吗?
But in I have specified to ignore .mat files in .gitignore. So when pushing the repository on github, the ignored files are not added.
没有添加被忽略的文件,因为您没有添加它们:) 不是因为 .gitignore
.
I can upload the files but that way the user who clone the repository later won't download those files when cloning.
这是错误的。如果这些文件在存储库中,它们将被克隆。因此,一种方法是 git add --force
() 他们并提交。
.gitignore
会在 运行 git status
时更改 "Untracked files" 的输出 - 如果存在文件或文件类型,则它不会显示在 "Untracked files" 列表。但是您仍然可以添加并提交它。
如果您希望任何 .mat
文件从现在起 显示在 "Untracked files" 列表中,您只应修改 .gitignore
。但是,如果您只想将一些特定的添加到您的存储库中,仅此而已,那么您不应该修改它。
有关详细信息,请参阅 gitignore documentation。