.gitignore not working: files that should be ignored still get committed

后端 未结 9 1557
暗喜
暗喜 2020-12-24 12:37

I\'m trying to create a new git repository from existing folder. I\'ve created a .gitignore file in the root of the folder. But if I say

git add         


        
相关标签:
9条回答
  • 2020-12-24 13:07

    Your file must still be tracked, you can see by doing git status that will show you that your file is modified even if it's in .gitignore
    You need to do this:

    git update-index --assume-unchanged [path_to_file]
    
    0 讨论(0)
  • 2020-12-24 13:12

    Comment line as the first line of the file is critical! I spent considerable time trying to exclude files only to find that GIT was ignoring the first line in the ignore file.

    0 讨论(0)
  • 2020-12-24 13:14

    Try "git add ." instead.

    Also, it works for me (on Linux):

    $ git init
    $ echo foo > .gitignore
    $ echo foo > foo
    $ echo bar > bar
    $ git add -v *
    The following paths are ignored by one of your .gitignore files:
    foo
    Use -f if you really want to add them.
    fatal: no files added
    
    0 讨论(0)
提交回复
热议问题