Search code examples
gitgithubrepositorygitignoregit-clone

How to upload ignored files to github repository


In my local repository, I have 8 files

enter image description here

But in I have specified to ignore .mat files in .gitignore. So when pushing the repository on github, the ignored files are not added.
But I want anyone who clones my repository later, have the .mat files and photos as examples of the data which work with the program.

I can upload the files but that way the user who clone the repository later won't download those files when cloning.

I also can modify the .gitignore file and commit adding .mat files to include them on my github repository.

But is there any other way?


Solution

  • But in I have specified to ignore .mat files in .gitignore. So when pushing the repository on github, the ignored files are not added.

    The ignored files are not added because you didn't add them :) not because of .gitignore.

    I can upload the files but that way the user who clone the repository later won't download those files when cloning.

    This is wrong. If these files are in the repository they will be cloned. So one way to go is to git add --force () them and commit.

    .gitignore would change the output of "Untracked files" when running git status - if a file or file type is there then it wouldn't be shown in "Untracked files" list. But you can still add and commit it.

    You should only modify .gitignore if you want any .mat files to be shown from now on in "Untracked files" list. But if you just want to add a few specific ones to your repository and that's it then you shouldn't modify it.

    See gitignore documentation for more info.