Search code examples
windowsgithubgitignore

Why is gitignore not working even after i put the file name in?


I have a file called sohuku.txt. I have another folder named .gitignore.txt inside which I have put 'sohuku.txt', but when I type 'git add .' in PowerShell and then type git status, it shows the file in changes to be committed. what to do?


Solution

  • create .gitignore file in your root / directory without any extension.

    /
      src
         index.js
      .gitignore
    

    want to remove the .txt files, just add in the .gitignore file

    *.txt
    

    and remove the old commit:

    $ git reset HEAD~                                          
    << edit files as necessary >>                              
    $ git add ...                                              
    $ git commit -c ORIG_HEAD
    

    Undo git to learn more