There is a Projects folder structure:

│ .babelrc │ .configs │ .gitignore │ server.js │ └───src ├───Build │ bundle.js │ ├───Scripts │ scripts.js │ └───Styles style.css 

If you initialize git in the root folder (Projects), then the src folder is uploaded to the repository, and there it is not needed just to understand its contents. Is it possible to do this so git would work with the src folder as the root? The solution would be to initialize git in the src folder itself, but I want to separate all the configuration files from the code. Is it possible to realize this?

  • one
    In this case, it will be good to add all this to the repository - andreymal

1 answer 1

If you consider the .gitignore file "configuration" - then no, it is impossible. This file must be no higher than the repository root - and you do not want to mix it with the code.

More precisely, there is one option, but I would not recommend it to you. The contents of .gitignore can be transferred to the .git / info / exclude file - then it will be “separated” from the code and you can transfer the repository root to where it suits you. But I do not recommend doing so - because the .git / info / exclude file will not be synchronized between different repositories, and it will have to be re-configured every time.


But what is the general problem of finding the src folder in the repository? On the contrary, it turns out quite comfortable structure. In the future, you may need to store in the repository documentation, tests or scripts of the system of continuous integration - and a separate folder for the code will be useful.

  • .gitignore ... must be in the root of the repository - not quite right. its contents will influence the directory in which it is located and on all subdirectories. see man gitignore . - aleksandr barakin
  • @alexanderbarakin hmm, really ... Corrected. - Pavel Mayorov
  • I would love to leave the src folder but in the repository which is located on github another folder architecture ... - Pavel
  • one
    @Pavel then copy it and do not invent it. The folder structure must be the same for all developers, otherwise there may be problems. For example, with the assembly. - Pavel Mayorov