1

New to git, I have searched a lot, didn't find a robust solution.

I got 2 projects, A and B.
A contains [A code] and [SHARED CODE], B contains [B code] and [SHARED CODE].

With svn, I could put a svn external in project B that links to subdirectory of project A, meaning A->[SHARED CODE].

However, it seems git does not allow partial clone, so if I choose submodule, I have to make it 3 projects: SHARED CODE, A and B, that is painful.

Worse is, when I make some change in A->[SHARED CODE](which is a submodule), it seems quite hard to commit and push it, and a git pull operation on B does not automatically pull the latest code to B->[SHARED CODE].

So any convenient solution for this? Thanks.

1

1 Answer 1

2

Yet, submodule remains the right solution, especially since git1.8.2:

See "Git submodule new version update"

A submodule can be configured to follow the latest of a branch, so this would be enough to update all your submodules to the latest commit:

 git submodule update --remote

Yes, that means 3 repos, but that is consistent with the role a git repo is supposed to play: it represents a "component", that is a coherent group of file with its own independent history.

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

2 Comments

@user2530437 as in stackoverflow.com/a/13738951/6309, I presume? Seems nice.
@user2530437 be careful: That is not the git way and might cause you problems in the future. Git is not svn and will resist if you try to make it so ;).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.