In many integrated development environments, it is impossible in the usual way to make the same folder a local repository (for example, a git repository) and a project folder (now it doesn’t matter which projects you are talking about - this can be a website or an application in any programming language ). But everything is more convenient when both the repository and the project are in the same root folder, especially since if you attach a project folder to the repository folder, the project tree, which is in many IDEs, may not give access outside the project root directory. In addition, the readme file is usually placed in the root of the repository, rather than the project (if it doesn’t match), and I would also like to edit it in the environment.

  • one
    Do not quite understand what you mean. In my universe, a local repository can be created almost anywhere, at least in / , even directly in C:\ . (Well, in / proc / will not work). - Nick Volynkin ♦
  • one
    "in the usual way" - and what is the usual method for you? - Nick Volynkin ♦
  • Well, for example, in NetBeans in the usual way, I mean creating a new project through the wizard to create a new project. If you select “Initialize a Git repository” in the NetBeans menu and then start creating a project, NetBeans will definitely create a project folder inside the one you specify. - Bokov Gleb
  • @GurebuBokofu I don’t see in netbeans tags :-) - Pavel Mayorov

1 answer 1

create file / directories inside git-storage (otherwise - git-repository), i.e. in the directory with the name (by default) .git , of course you can:

 $ touch .git/file 

but git (by default) won't allow you to control versions of this file:

 $ git add .git/file error: Invalid path '.git/file' error: unable to add .git/file to index fatal: adding files failed 

therefore it is better to keep the working directory files ( working directory ) separately: by default, in the same directory as the directory with the repository.

  • Thank you for your reply! I did not mean the folder. .git , I had in view of the rotator folder in relation to the directory. .git . I will ask this: if the .git folder is among the project files, that is, inside the project folder, will it be normal? ( ProjectFolder/.git ) - Gleb
  • one
    Yes, this is normal and that is exactly what the git program does by default: the file / directories whose history you are tracking are usually located in the same directory as the repository itself (that is, the .git subdirectory) - aleksandr barakin
  • Clear! Then I will do that now! Thanks again for the reply. - Gleb
  • Alexander, aren't you going to stand for election? I remember how you persistently and methodically raked up queues of checks and lists of unanswered. We now just need such a person. - Nick Volynkin ♦
  • @NickVolynkin, ru.meta.stackoverflow.com/questions/6114/… - aleksandr barakin