How to ignore a file or directory in git, be it tracked, untracked or even part of commit

后端 未结 4 982
悲&欢浪女
悲&欢浪女 2021-01-19 23:29

I want to completely ignore a part of a git repository. The directory is currently tracked in the repository and I\'d like to ensure that

  • whenever anybody chan
4条回答
  •  没有蜡笔的小新
    2021-01-19 23:58

    You can try with following line at beginning of .gitignore file :

    !.gitignore
    

    I think this should force git to ignore listed firs/files. I don't know is it best way, but it works in my case. e.g.

    !.gitignore
    my_dir/
    some_dir/
    

    Note: Of course you should git add and commit .gitignore than push to origin.

提交回复
热议问题