Where does the .gitignore file belong?

后端 未结 8 901
我寻月下人不归
我寻月下人不归 2020-12-12 08:43

Does the .gitignore file belong in the .git folder structure somewhere or in the main source files?

相关标签:
8条回答
  • 2020-12-12 09:05

    When in doubt just place it in the root of your repository. See https://help.github.com/articles/ignoring-files/ for more information.

    0 讨论(0)
  • 2020-12-12 09:13

    Put .gitignore in the working directory. It doesn't work if you put it in the .git (repository) directory.

    $ ls -1d .git*
    .git
    .gitignore
    
    0 讨论(0)
  • 2020-12-12 09:16

    Also, if you create a new account on Github you will have the option to add .gitignore and it will be setup automatically on the right/standard location of your working place. You don't have to add anything in there at the begin, just alter the contents any time you want.

    0 讨论(0)
  • 2020-12-12 09:19

    If you want to do it globally, you can use the default path git will search for. Just place it inside a file named "ignore" in the path ~/.config/git

    (so full path for your file is: ~/.config/git/ignore)

    0 讨论(0)
  • 2020-12-12 09:22

    You may also find a global .gitignore directly at the ~ path if you haven't created it in your folder project. This file is taken into account by all your .git projects.

    0 讨论(0)
  • 2020-12-12 09:26

    In the simple case, a repository might have a single .gitignore file in its root directory, which applies recursively to the entire repository. However, it is also possible to have additional .gitignore files in subdirectories. The rules in these nested .gitignore files apply only to the files under the directory where they are located. The Linux kernel source repository has 206 .gitignore files.

    -- this is what i read from progit.pdf(version 2), P32

    0 讨论(0)
提交回复
热议问题