0

In our project, one person is writting plain SCSS, and other people are working on Rails app. I regulary have to copy the SCSS from the simple repo into the Rails asset pipeline. The copy is exact. So I would like to know how to setup git so that I could do it on a regular basis? (as convenient as possible)

Aurimas
  • 2,577
  • 5
  • 26
  • 37
  • I know you can do sparse checkout http://stackoverflow.com/a/13738951/2190425 , but what if I need to do it within repository, does that make any difference? – Aurimas Mar 14 '17 at 17:47

1 Answers1

1

Well, I guess git submodules is the feature you're looking for. See the git documentation at https://git-scm.com/book/en/v2/Git-Tools-Submodules

If I sound a little hesitant, it's because I've always thought it was a bit odd to pull in dependencies with the source control software; if you could automate this through your build tools I think it might be a more natural solution. But if doing it as a git operation is the way to go for you, I'd look at the above.

UPDATE

Follow-up question from comments: Can a submodule be set up for just a sub-folder of the other project?

So we have project A

projectA/
    stuff/
    other-stuff/
    shared-stuff/

and project B

projectB/
    more-stuff/
    unrelated-stuff/

and we want projectA/shared-stuff to show up also as projectB/shared-stuff/ and we're talking about how to do this with submodules.

I don't know that a submodule can be any more specific than "embed this commit of that repo". But one suggestion would be to split the shared code into its own repo

shared-stuff/

Then add shared-stuff as a submodule of both project A and project B

projectA repo       | shared-stuff repo |  projectB repo
==================================================================
/                   |                   |  /
    stuff/          |                   |      more-stuff/
    other-stuff/    |                   |      unrelated-stuff/
    (shared-stuff)--> /                 <--    (shared-stuff)

Of course because submodule mappings are contained within the repo using the submodule, the folder names (or locations in the parent projects' trees) don't have to match...

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52