Search code examples
githubgitignore

How to recover files from .gitignore


while uploading files to the repository in GitHub, I accidentally click to the button to ignore the files from the upload. Now these files are in a folder called '.gitignore'. How can I recover these files?

I'm able to see and modify them, I just want to know how to upload them in the repository.

Thanks in advance


Solution

  • I think you misunderstand the concept of .gitignore "folder".
    It is instead a text file, with the path of the ignored directories or files.

    Consider the following .gitignore file.

    foo/bar.txt
    foobar/
    

    This will tell git to ignore the directory foobar as well as the file foo/bar.txt, and therefore you won't be able add the files to a commit or push it to a remote repository.

    But you can simply remove a file from the list of ignored files and directories by opening the .gitignore file, deleting the line with the corresponding file and saving the .gitignore file. You then should the be able to add the file to a commit and push it to a remote repository.

    More information about .gitignore can be found here