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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
user2530437
  • 33
  • 1
  • 5
  • seems http://blog.quilitz.de/2010/03/checkout-sub-directories-in-git-sparse-checkouts/comment-page-1/ is a solution, didn't figure out yet, but working on it. – user2530437 Jul 02 '13 at 04:04

1 Answers1

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @user2530437 as in http://stackoverflow.com/a/13738951/6309, I presume? Seems nice. – VonC Jul 02 '13 at 07:03
  • @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 ;). – Chronial Jul 02 '13 at 09:54