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)

1
  • I know you can do sparse checkout stackoverflow.com/a/13738951/2190425 , but what if I need to do it within repository, does that make any difference? Commented Mar 14, 2017 at 17:47

1 Answer 1

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...

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, how would you add a submodule, but not the whole repo, but only a folder of that submodule, is it possible?
I don't know if that's possible. Could you put the subfolder in its own repo and make that a submodule of both projects?
Hmm. not following, can you clarify?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.