Add a submodule to each branch of a parent project












1















I have a project called channel, which has only one branch -- master. And I have another project called bigTest, which has four branches -- master, dev, stable, release.

Nowadays I want to add channel to the root directory of bigTest as a submodule of each branch of bigTest. I used git submodule add <url> for each branch of four. However I got
modified: channel (untracked content) and modified .gitmodules appending branch = dev even though I used git config -f .gitmodules submodule.channel.branch dev on dev branch.

What should I do in order to add a submodule master to multiple branches of a project? Thank you!










share|improve this question



























    1















    I have a project called channel, which has only one branch -- master. And I have another project called bigTest, which has four branches -- master, dev, stable, release.

    Nowadays I want to add channel to the root directory of bigTest as a submodule of each branch of bigTest. I used git submodule add <url> for each branch of four. However I got
    modified: channel (untracked content) and modified .gitmodules appending branch = dev even though I used git config -f .gitmodules submodule.channel.branch dev on dev branch.

    What should I do in order to add a submodule master to multiple branches of a project? Thank you!










    share|improve this question

























      1












      1








      1


      1






      I have a project called channel, which has only one branch -- master. And I have another project called bigTest, which has four branches -- master, dev, stable, release.

      Nowadays I want to add channel to the root directory of bigTest as a submodule of each branch of bigTest. I used git submodule add <url> for each branch of four. However I got
      modified: channel (untracked content) and modified .gitmodules appending branch = dev even though I used git config -f .gitmodules submodule.channel.branch dev on dev branch.

      What should I do in order to add a submodule master to multiple branches of a project? Thank you!










      share|improve this question














      I have a project called channel, which has only one branch -- master. And I have another project called bigTest, which has four branches -- master, dev, stable, release.

      Nowadays I want to add channel to the root directory of bigTest as a submodule of each branch of bigTest. I used git submodule add <url> for each branch of four. However I got
      modified: channel (untracked content) and modified .gitmodules appending branch = dev even though I used git config -f .gitmodules submodule.channel.branch dev on dev branch.

      What should I do in order to add a submodule master to multiple branches of a project? Thank you!







      git-branch git-submodules git-untracked






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 2 at 3:42









      Bryan YUBryan YU

      358




      358
























          1 Answer
          1






          active

          oldest

          votes


















          1














          The submodule.channel.branch should be set to master only, since the remote submodule repo (channel) has only one branch to follow anyway.



          Once declared, you need add, commit and push from bigTest, since the .gitmodules has changed, and a gitlink (special entry in the index) representing channel root folder has been created.




          However git status shows: Untracked files: (use "git add <file>..." to include in what will be committed) channel/ when I checkout master of bigTest.




          The OP finds out why:




          Yes, I compile and produce something in the submodule folder.

          I can conclude that Git will show untracked content if something new created from submodules.




          I recommend putting what is produce in the .gitignore of the submodule.






          share|improve this answer


























          • I can still not add channel to index in dev, stable or release branch of bigTest repo, showing modified: channel (untracked content). However git status shows: Untracked files: (use "git add <file>..." to include in what will be committed) channel/ when I checkout master of bigTest. That seems like I could add and commit channel submodule to master of bigTest.

            – Bryan YU
            Jan 2 at 6:01













          • @BryanYU what git status shows when executed from within the channel submodule folder?

            – VonC
            Jan 2 at 6:02











          • You make sense! There are something left in submodule. After I commit them in submodule, modified: Channel_ANS_test (new commits) is shown in bigTest directory. Thank you! What should I do? I should push changes to remote in submodule and then commit and push changes to remote in parent repo.

            – Bryan YU
            Jan 2 at 6:14











          • Strange, there should not be anything "changed" in the submodule folders. But if you do commit inside a submodule, you should push to the submodule remote repo, then go to the main parent repo, add, commit and push as well.

            – VonC
            Jan 2 at 6:23











          • Yes, I compile and produce sth. in the submodule folder. I can conclude that the git will show untracked content if something new created from submodules.

            – Bryan YU
            Jan 2 at 6:31











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000969%2fadd-a-submodule-to-each-branch-of-a-parent-project%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          The submodule.channel.branch should be set to master only, since the remote submodule repo (channel) has only one branch to follow anyway.



          Once declared, you need add, commit and push from bigTest, since the .gitmodules has changed, and a gitlink (special entry in the index) representing channel root folder has been created.




          However git status shows: Untracked files: (use "git add <file>..." to include in what will be committed) channel/ when I checkout master of bigTest.




          The OP finds out why:




          Yes, I compile and produce something in the submodule folder.

          I can conclude that Git will show untracked content if something new created from submodules.




          I recommend putting what is produce in the .gitignore of the submodule.






          share|improve this answer


























          • I can still not add channel to index in dev, stable or release branch of bigTest repo, showing modified: channel (untracked content). However git status shows: Untracked files: (use "git add <file>..." to include in what will be committed) channel/ when I checkout master of bigTest. That seems like I could add and commit channel submodule to master of bigTest.

            – Bryan YU
            Jan 2 at 6:01













          • @BryanYU what git status shows when executed from within the channel submodule folder?

            – VonC
            Jan 2 at 6:02











          • You make sense! There are something left in submodule. After I commit them in submodule, modified: Channel_ANS_test (new commits) is shown in bigTest directory. Thank you! What should I do? I should push changes to remote in submodule and then commit and push changes to remote in parent repo.

            – Bryan YU
            Jan 2 at 6:14











          • Strange, there should not be anything "changed" in the submodule folders. But if you do commit inside a submodule, you should push to the submodule remote repo, then go to the main parent repo, add, commit and push as well.

            – VonC
            Jan 2 at 6:23











          • Yes, I compile and produce sth. in the submodule folder. I can conclude that the git will show untracked content if something new created from submodules.

            – Bryan YU
            Jan 2 at 6:31
















          1














          The submodule.channel.branch should be set to master only, since the remote submodule repo (channel) has only one branch to follow anyway.



          Once declared, you need add, commit and push from bigTest, since the .gitmodules has changed, and a gitlink (special entry in the index) representing channel root folder has been created.




          However git status shows: Untracked files: (use "git add <file>..." to include in what will be committed) channel/ when I checkout master of bigTest.




          The OP finds out why:




          Yes, I compile and produce something in the submodule folder.

          I can conclude that Git will show untracked content if something new created from submodules.




          I recommend putting what is produce in the .gitignore of the submodule.






          share|improve this answer


























          • I can still not add channel to index in dev, stable or release branch of bigTest repo, showing modified: channel (untracked content). However git status shows: Untracked files: (use "git add <file>..." to include in what will be committed) channel/ when I checkout master of bigTest. That seems like I could add and commit channel submodule to master of bigTest.

            – Bryan YU
            Jan 2 at 6:01













          • @BryanYU what git status shows when executed from within the channel submodule folder?

            – VonC
            Jan 2 at 6:02











          • You make sense! There are something left in submodule. After I commit them in submodule, modified: Channel_ANS_test (new commits) is shown in bigTest directory. Thank you! What should I do? I should push changes to remote in submodule and then commit and push changes to remote in parent repo.

            – Bryan YU
            Jan 2 at 6:14











          • Strange, there should not be anything "changed" in the submodule folders. But if you do commit inside a submodule, you should push to the submodule remote repo, then go to the main parent repo, add, commit and push as well.

            – VonC
            Jan 2 at 6:23











          • Yes, I compile and produce sth. in the submodule folder. I can conclude that the git will show untracked content if something new created from submodules.

            – Bryan YU
            Jan 2 at 6:31














          1












          1








          1







          The submodule.channel.branch should be set to master only, since the remote submodule repo (channel) has only one branch to follow anyway.



          Once declared, you need add, commit and push from bigTest, since the .gitmodules has changed, and a gitlink (special entry in the index) representing channel root folder has been created.




          However git status shows: Untracked files: (use "git add <file>..." to include in what will be committed) channel/ when I checkout master of bigTest.




          The OP finds out why:




          Yes, I compile and produce something in the submodule folder.

          I can conclude that Git will show untracked content if something new created from submodules.




          I recommend putting what is produce in the .gitignore of the submodule.






          share|improve this answer















          The submodule.channel.branch should be set to master only, since the remote submodule repo (channel) has only one branch to follow anyway.



          Once declared, you need add, commit and push from bigTest, since the .gitmodules has changed, and a gitlink (special entry in the index) representing channel root folder has been created.




          However git status shows: Untracked files: (use "git add <file>..." to include in what will be committed) channel/ when I checkout master of bigTest.




          The OP finds out why:




          Yes, I compile and produce something in the submodule folder.

          I can conclude that Git will show untracked content if something new created from submodules.




          I recommend putting what is produce in the .gitignore of the submodule.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 2 at 11:31

























          answered Jan 2 at 5:45









          VonCVonC

          845k29426783233




          845k29426783233













          • I can still not add channel to index in dev, stable or release branch of bigTest repo, showing modified: channel (untracked content). However git status shows: Untracked files: (use "git add <file>..." to include in what will be committed) channel/ when I checkout master of bigTest. That seems like I could add and commit channel submodule to master of bigTest.

            – Bryan YU
            Jan 2 at 6:01













          • @BryanYU what git status shows when executed from within the channel submodule folder?

            – VonC
            Jan 2 at 6:02











          • You make sense! There are something left in submodule. After I commit them in submodule, modified: Channel_ANS_test (new commits) is shown in bigTest directory. Thank you! What should I do? I should push changes to remote in submodule and then commit and push changes to remote in parent repo.

            – Bryan YU
            Jan 2 at 6:14











          • Strange, there should not be anything "changed" in the submodule folders. But if you do commit inside a submodule, you should push to the submodule remote repo, then go to the main parent repo, add, commit and push as well.

            – VonC
            Jan 2 at 6:23











          • Yes, I compile and produce sth. in the submodule folder. I can conclude that the git will show untracked content if something new created from submodules.

            – Bryan YU
            Jan 2 at 6:31



















          • I can still not add channel to index in dev, stable or release branch of bigTest repo, showing modified: channel (untracked content). However git status shows: Untracked files: (use "git add <file>..." to include in what will be committed) channel/ when I checkout master of bigTest. That seems like I could add and commit channel submodule to master of bigTest.

            – Bryan YU
            Jan 2 at 6:01













          • @BryanYU what git status shows when executed from within the channel submodule folder?

            – VonC
            Jan 2 at 6:02











          • You make sense! There are something left in submodule. After I commit them in submodule, modified: Channel_ANS_test (new commits) is shown in bigTest directory. Thank you! What should I do? I should push changes to remote in submodule and then commit and push changes to remote in parent repo.

            – Bryan YU
            Jan 2 at 6:14











          • Strange, there should not be anything "changed" in the submodule folders. But if you do commit inside a submodule, you should push to the submodule remote repo, then go to the main parent repo, add, commit and push as well.

            – VonC
            Jan 2 at 6:23











          • Yes, I compile and produce sth. in the submodule folder. I can conclude that the git will show untracked content if something new created from submodules.

            – Bryan YU
            Jan 2 at 6:31

















          I can still not add channel to index in dev, stable or release branch of bigTest repo, showing modified: channel (untracked content). However git status shows: Untracked files: (use "git add <file>..." to include in what will be committed) channel/ when I checkout master of bigTest. That seems like I could add and commit channel submodule to master of bigTest.

          – Bryan YU
          Jan 2 at 6:01







          I can still not add channel to index in dev, stable or release branch of bigTest repo, showing modified: channel (untracked content). However git status shows: Untracked files: (use "git add <file>..." to include in what will be committed) channel/ when I checkout master of bigTest. That seems like I could add and commit channel submodule to master of bigTest.

          – Bryan YU
          Jan 2 at 6:01















          @BryanYU what git status shows when executed from within the channel submodule folder?

          – VonC
          Jan 2 at 6:02





          @BryanYU what git status shows when executed from within the channel submodule folder?

          – VonC
          Jan 2 at 6:02













          You make sense! There are something left in submodule. After I commit them in submodule, modified: Channel_ANS_test (new commits) is shown in bigTest directory. Thank you! What should I do? I should push changes to remote in submodule and then commit and push changes to remote in parent repo.

          – Bryan YU
          Jan 2 at 6:14





          You make sense! There are something left in submodule. After I commit them in submodule, modified: Channel_ANS_test (new commits) is shown in bigTest directory. Thank you! What should I do? I should push changes to remote in submodule and then commit and push changes to remote in parent repo.

          – Bryan YU
          Jan 2 at 6:14













          Strange, there should not be anything "changed" in the submodule folders. But if you do commit inside a submodule, you should push to the submodule remote repo, then go to the main parent repo, add, commit and push as well.

          – VonC
          Jan 2 at 6:23





          Strange, there should not be anything "changed" in the submodule folders. But if you do commit inside a submodule, you should push to the submodule remote repo, then go to the main parent repo, add, commit and push as well.

          – VonC
          Jan 2 at 6:23













          Yes, I compile and produce sth. in the submodule folder. I can conclude that the git will show untracked content if something new created from submodules.

          – Bryan YU
          Jan 2 at 6:31





          Yes, I compile and produce sth. in the submodule folder. I can conclude that the git will show untracked content if something new created from submodules.

          – Bryan YU
          Jan 2 at 6:31




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000969%2fadd-a-submodule-to-each-branch-of-a-parent-project%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Monofisismo

          Angular Downloading a file using contenturl with Basic Authentication

          Olmecas