Search code examples
gitgithubgit-submodulesgitignoregithub-desktop

How do I keep a repository within a repository up to date with Github Desktop


I have three locals folders for which I create a repository on github (let's assume we only work with one branch master):

  • Folder Utils
  • Folder A
  • Folder B

Now I need the Folder Utils within the workspaces of both Folder A and B. I might make changes to Folder Utils within A and B but also within Folder Utils.

My objective is to keep the Folder Utils up to date at all time on all my local folders. How do I do this in the most effective matter?

I know that I can clone Folder Utils within Folder A. However, when making changes to Folder Utils within A, I have to separately commit and push the changes from clone Utils in A. Then I need to go into B and Utils amd pull the changes. Isn't there a way to only commit to A and thus take these changes into account into all folders?

Also, when someome else has made changes to Utils in lets say Folder B or Utils, I wont see the changes in Folder A when I fetch the origin in A - I need to fetch changes within thr clone Utils in A. This obviously requires me to fetch changes for all the cloned folders within A and B at all time (so I need to manually fetch it 4 x 4 + 1. This might work for two/three folders, but if I have > 50 folders this process becomes cumbersome.

What is therefore the general recommended workflow to keep these cloned folders inside up to date at all time? How do you achieve this with GH Desktop


Solution

  • What you are going to want to do is use Git Submodules, which do as you describe - include (embed) repositories as sub-directories within other repositories. The link provided will have you on your way to working with them.