Git subtree pushes new tree

I worked with for a long time git submodules, and I was pleased with it. On the other hand, my colleagues complained about it (and many people on the Internet seem to hate too git submodule), and my manager decided to switch to git subtree.

I support (together with my supervisor) a project with 4 submodulesin it. Each submodule in itself is an independent project and was developed for different projects of our company. Our software has different dependencies on these modules, and to support deployment, we created this project with four submodules.

Now my supervisor has created a new branch, where he got rid of the submodules and added them instead git subtree. An autonomous repo of one of these ex-somodules (say mod1) looked like this:

standalone repo

        D--E--F  dev_feature_X
       /   
A--B--C          master

My supervisor used dev_feature_Xwhen added mod1using git subtree.

Last week I had to fix this feature, and I tried to make separate commits. I wanted to make changes mod1to its offline repository, so I performed

$ git subtree push --prefix=mod1 user@server:mod1 feature_X

In offline mode, mod1I did a repo git fetchand saw that a new branch was created origin/feature_X.

  dev_feature_X
              |   
              v   
        D--E--F--P--Q--R  feature_X
       /   
A--B--C                   master

This new branch was part of the tree, so I was able to merge it without any problems. I deleted the branch origin/feature_Xbecause I no longer need it, and it was already part of the tree.

, . , mod1 .

$ git subtree push --prefix=mod1 user@server:mod1 feature_X

repo mod1 git fetch, subtree push

           dev_feature_X
                       |   
                       v   
        D--E--F--P--Q--R   A'--B'--C'--...--R'--O feature_X
       /   
A--B--C                   master

.

, git subtree push , "" (P, Q, R), , . , R O, O .

- ? man- , , , , , .

+4

Source: https://habr.com/ru/post/1655662/


All Articles