简体   繁体   中英

PhpStorm - Nested Git Repositories

There is a main "project" repository and below there are 2 "module" repositories. Directory structure is:

Project (Git)
- File1
- File2
- Modules
--- Module1 (Git)
--- Module2 (Git)

Everything seems to be setup fine so far (there are 3 entries in "settings -> version control") and VCS operations can be done per each repository.

Now when pulling changes from a module like "Module1", i want this changes to be commitable to "Project" repository, too.

The same when modifying something in "Module1": I want to commit this changes to "Module1" itself but also to the "Project" repository.

Is this possible?

The idiomatic way to represent nested git repositories is via git submodule or git subtree :

  • git submodule is a built-in feature that allows you to commit the checked-out version of an external tree as part of your repo. Git will populate that directory as part of checkout, but the files in the nested repository are not kept as part of your outer repo. This might be a good option for advanced users or very large repos.
  • git subtree is a script in the git/contrib directory . It manages the import of another repo into yours, so users and their tools don't need to be aware of the import. Your repo will grow to include the entire history of the repo you import as a subtree. This might be a good option for smaller or first-party repos.

It appears that as of September 2018 PhpStorm supports submodules . The JetBrains IDEA documentation alludes to them , as described in the SO answer to Work with Git Tool - Submodules with PhpStorm .

I don't know about formal support for subtrees, which are a contrib feature rather than a core feature, and in any case are much more like normal commits as far as git is concerned.

See also:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM