1

I am using Git for the first time. There is a project on Git that i need to do a "get latest".

Now this solution has other project dependencies. So do i need to do a git clone on each project to my local machine or is there a switch in the git clone that can fetch the project and all other projects it depends on ?

Debbie.S
  • 167
  • 11
  • 1
    Git has no such thing as dependencies. It has submodules though. Are the other repositories configured as submodules? Or does the project just have instructions to clone other repositories into its directory tree? Please read [ask] and provide all relevant details. – CodeCaster May 13 '20 at 05:03
  • @CodeCaster Actually that's not true. Git Submodule and Git Subtree are about managing git repo dependencies. From https://www.atlassian.com/git/tutorials/git-subtree: "git subtree lets you nest one repository inside another as a sub-directory. It is one of several ways Git projects can manage project dependencies." – Inigo May 13 '20 at 05:15
  • Debbie, the answer depends on how those dependencies are represented. Git sbumodule? Git subtree? There are other mechanisms too. The README file for that repo might have the answers. – Inigo May 13 '20 at 05:17
  • @Inigo _"Actually that's not true"_ - what isn't? Sure, I forgot to mention subtrees, but who uses those? The gist of my comment is: we can't know, tell us more about the project, which you repeated in your second comment. – CodeCaster May 13 '20 at 05:22
  • Does this answer your question? [How to "git clone" including submodules?](https://stackoverflow.com/questions/3796927/how-to-git-clone-including-submodules) – CodeCaster May 13 '20 at 05:25
  • there is no readme in either of the 2 repositories , as it says "Add a README with an overview of your project." , also the if the repository was a submodule i assume it would have a .gitmodules located at the root reposiroy , and there is none. – Debbie.S May 13 '20 at 05:28
  • @CodeCaster "Git has no such thing as dependencies." False. Also, are you calling out people's choice of upvote or downvote in the comments? That's **highly inappropriate**. – Inigo May 13 '20 at 05:30
  • So in my situation , i need to speak with the owner of the repo to restructure the repos from now on and start to use submodules as it would be more efficient ? In my case i guess i need to clone individual repos , as there doesnt seem to be any way , unless i am missing something ? Once submodules is introduced we can use as @CodeCaster mentione in the link How to "git clone" including submodules? – Debbie.S May 13 '20 at 05:36
  • @Debbie.S Again, read my answer: it depends on the nature of the dependencies. – VonC May 13 '20 at 05:38
  • 1
    Yes , my solution is a Visual Studio 2019 solution and in the solution under Dependencies->Projects, there is the name of the project it depends on. Now I thought I could clone from git in one go and retrieve the entire solution with all dependencies, obviously not as it has not been set up that way. So i need to clone each individual project from git until submodules are introduced from now on . – Debbie.S May 13 '20 at 05:44
  • @Debbie.S OK. I have included your comment in the answer for more visibility. – VonC May 13 '20 at 05:46
  • @Inigo no, Git doesn't have **dependencies**. It has submodules and subtrees, but those are not dependencies. Dependencies are, in this context, other projects (or their output) required to build or run a project. Git doesn't know nor care about those, it deals in changes to files, not the relations between software projects. Also, you generally don't want to use submodules for dependency management, for various reasons. There's a reason packaging and package managers exist. And yes, I did comment on the voting on this (unclear, IMHO) question, but have removed it. – CodeCaster May 13 '20 at 05:47
  • _"under Dependencies->Projects, there is the name of the project it depends on"_ - they should already be in the solution. Aren't they? – CodeCaster May 13 '20 at 05:54
  • It is in the solution csproj file, but when i clone it doesnt get it – Debbie.S May 13 '20 at 05:55
  • A csproj file is a _project_, a solution consists of zero or more projects. – CodeCaster May 13 '20 at 06:05
  • sorry typo .. the solution yes has 2 projects . project 1 which is set as default depends on project 2, and project 2 wasnt brought down when i cloned project 1 from repo – Debbie.S May 13 '20 at 06:13

1 Answers1

5

You need to check the nature of those dependencies:

In the former case, if submodules are involved, you would see a .gitmodules file listing the external repositories.

A simple git clone --recurse-submodules would be enough to clone all repositories involved.

The OP Debbie.S confirms in the comments:

My solution is a Visual Studio 2091 solution and in the solution under Dependencies->Projects, there is the name of the project it depends on.

Now I thought I could clone from Git in one go and retrieve the entire solution with all dependencies, obviously not as it has not been set up that way.

So I need to clone each individual project from Git until submodules are introduced from now on.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250