Download Scott Chacon
Transcript
C H A P T E R 6 N G I T TO O LS You have to see who last changed the submodule: cephkc)-n]_g _kiiep41]/aaa5524,,b_b]5-a.--5/3.``0-3.^b32234 =qpdkn6O_kpp?d]_kj8o_d]_kj<ci]eh*_ki: @]pa6Pdq=ln5,56-56-0.,,5),3,, ]``a`]oq^ik`qhanabanaj_aEsehhjarani]galq^he_*d]d]d]d]d] Then, you e-mail that guy and yell at him. Superprojects Sometimes, developers want to get a combination of a large project’s subdirectories, depending on what team they’re on. This is common if you’re coming from CVS or Subversion, where you’ve defined a module or collection of subdirectories, and you want to keep this type of workflow. A good way to do this in Git is to make each of the subfolders a separate Git repository and then create superproject Git repositories that contain multiple submodules. A benefit of this approach is that you can more specifically define the relationships between the projects with tags and branches in the superprojects. Issues with Submodules Using submodules isn’t without hiccups, however. First, you must be relatively careful when working in the submodule directory. When you run cepoq^ik`qhaql`]pa, it checks out the specific version of the project, but not within a branch. This is called having a detached head— it means the DA=@ file points directly to a commit, not to a symbolic reference. The issue is that you generally don’t want to work in a detached head environment, because it’s easy to lose changes. If you do an initial submodule update, commit in that submodule directory without creating a branch to work in, and then run cepoq^ik`qhaql`]pa again from the superproject without committing in the meantime, Git will overwrite your changes without telling you. Technically, you won’t lose the work; but you won’t have a branch pointing to it, so it will be difficult to retrieve. To avoid this issue, create a branch when you work in a submodule directory with cep _da_gkqp)^skng or something equivalent. When you do the submodule update a second time, it will still revert your work, but at least you have a pointer to get back to. Switching branches with submodules in them can also be tricky. If you create a new branch, add a submodule there, and then switch back to a branch without that submodule, you still have the submodule directory as an untracked directory: cep_da_gkqp)^n]_g Osep_da`pk]jas^n]j_dn]_g cepoq^ik`qha]``cep<cepdq^*_ki6o_d]_kj+n]_g*cepn]_g Ejepe]heva`ailpuCepnalkoepknuej+klp+iulnkf+n]_g+*cep+ *** Na_aerejck^fa_po6-,,!$/-40+/-40%(233*0.Ge>x/0Ge>+o(`kja* Naokhrejc`ahp]o6-,,!$-51.+-51.%(`kja* cep_kiiep)]i#]``a`n]_goq^ik`qha# 169