Use gitignore to nest repositories.

I want to nest 2 git repos. I have been reading into submodules and for a while i thought it was great, I think I may want something else. Here is my situation:

First I think I should mention that all of my servers host websites and are setup in a staging.domain.com and domain.com (live) pattern.

  • “Access denied” when pushing to remote repository via SSH
  • Git for Windows equivalent for open current directory command
  • phpstorm git pull --rebase
  • `git flow release finish` non-interactively
  • How to restore Git bare repository from local one
  • How can I view all the git repositories on my machine?
  • In each server I have a parent repo that is a website and a child repo which it my core library. I need my core to be the same on all of my servers but the website repos will all be unique to the server where they live. I want to write changes to the core, push to all staging domains simultaneously, then do some quality assurance, and push to all live servers.

    I originally though that submodules would meet my needs but the issue I have with them is that I need the cores to update all at once. If I use submodules my core will update but won’t take affect until the parent website runs git submodule update and git commit.

    I figure why not just use a gitignore to ignore the folder that the core is in and treat them like they’re separate entities. Has anyone else done this? What problems will I run into? Do you have any better suggestions?

    Thank you in advance.

  • How to set-up git with utf8 filenames in EGit
  • Adding users to Visual Studio Online so they are on all projects
  • When I clone project from Github to Visual Studio, all DLL file from nuget missing
  • Git when used with Mac and Windows simultaneously gives unnecessary conflicts
  • How do I run git rebase --interactive in non-interactive manner?
  • Is there a way to modify the width of elements in the IntelliJ statusbar (esp, the current git branch)
  • 3 Solutions collect form web for “Use gitignore to nest repositories.”

    Instead of submodules you can use git-subtree (Sample of usage)

    It seems you might benefit from a post-receive commit on your staging server, on which you could:

    • push your updates to a bare repo core
    • trigger the git submodule update for all the staging sites
      • cd to one server site /path/staging/site1
      • GIT_DIR=/path/staging/site1/.git WORK_TREE=/path/staging/site1/.git git submodule update
      • repeat for each site

    The idea would be:

    • one push
    • multiple updates
    • keeping the advantage of submodule (ie, recording the exact version of core your site is using)

    It depends on whether you want “git status” on the parent repo to return that the repo is clean. If you can live with “git status” on the parent repo returning something like “Untracked files:… core-libraries/”, then you can just have the core-libraries repo as an untracked child of the parent repo.

    Git really doesn’t care about untracked files & directories.

    Git Baby is a git and github fan, let's start git clone.