Search code examples
gitgithubpull

How to pull from one Github repository to multiple local repositories?


I have a WordPress parent theme and multiple WordPress website (all on the same filesystem) that use it. So how do I make sure with Git that each instance of the parent theme is synced with the version on Github? Without having to pull each instance individually.


Solution

  • You've asked how to keep multiple local repository clones up-to-date without having to pull each instance individually. Carl-Eric has addressed how to efficiently store multiple repositories on your filesystem. Here are some suggestions on keeping them up-to-date:

    One solution would be to set up a post-merge hook in one of the repositories that iterates across the others and performs the pull operation:

    #!/bin/sh
    
    unset GIT_DIR
    for repo in /path/to/repo1 /path/to/repo2; do
       ( cd $repo && git pull)
    done
    

    The post-merge script is run after a git pull operation.

    Having said that, the simplest option would be to have a single clone of the repository and then symlink to it from the other locations.