3

I have directory structure like so:

|-- ROOT
    |-- Project1
    |   |-- application
    |   |-- img
    |   |-- js
    |   |-- css
    |   `-- system
    |
    |-- Project2
    |   |-- application
    |   |-- img
    |   |-- js
    |   |-- css
    |   `-- system
    |-- Project3
    ....

Root folder contains total of x projects: "Project1", "Project2", "Project3" and so on.

Now i'd like to use git on "system", "css" and "js". These folders should be identical for each project. So how can sync all projects with git?

I'm guessing to create a "Master Project" and push new modifications to there and pull new version to all other projects. But that's pain in the a**..

What i'd like is to run some command/batch file to sync all at once. Eg if i have 6 projects and i modify something in project 1, how can i get this modification to all projects fast(instead of pushing Project1 to "Master" and pulling it 5 times)?

Is it possible?

Just for a record i'm working on a Windows machine.

Previous question: Git between multiple projects

Community
  • 1
  • 1
Kristian
  • 3,283
  • 3
  • 28
  • 52

2 Answers2

5

You still probably want to use a submodule. See this page in the git book.

Using submodules makes handling the types of changes that you are talking about fairly straightforward. See the second half of this answer which summarizes the process well.

I've modified my previous answer as I can see that this could be a bit of a pain for multiple projects if you need to keep them all in step as updating all the submodule commit references in the main project will take some time. As per the previous answer I suggest that you script this process if that is what you want to do.

It does have an advantage once the projects mature however as in my experience it often happens that all projects cannot be updated at once. Sometimes one project still requires an older version for a period of time. In this case you can just to update the required projects to reference the new commit in the submodule and then upgrade the others later when you have time.

Community
  • 1
  • 1
MikeD
  • 5,004
  • 1
  • 25
  • 39
  • Wow that seems to be excacly what i have looking for. Submodule was answer to my previous questin, but you just made that clear for me and linked to the right page. Thanks! – Kristian Mar 23 '12 at 11:37
  • I agree with your reference ;) – VonC Mar 23 '12 at 11:52
2

Using git submodule for those folders (if the master project is a different git project) would ease it a bit, but won't save you the trouble of pulling after a push.

Writing a bash script that does this reucrsively for each folder which is a git project or submodule should be fairly easy. maybe something like:

find -name css -type d -execdir git pull origin master ;

Not_a_Golfer
  • 47,012
  • 14
  • 126
  • 92