Changing GIT submodules URL/Branch to other URL/branch of same repository

GIT documentation and GIT Tools-Submodule discusses about Submodules operations such as add, status, init/deinit, update, checkout, merge commands etc. These commands have solid examples on how to work on submodules in a repository. Good GUI such as GItEx or TortoiseGIT or GitGUI clients for GIT Bash have these features implemented for submodule.

But, They lack behind in explaining on how to change a submodule from one URL to another or to change the path or to change the branch in the same submodule. Some developers are discarding/not using submodules for the same reason. There are lot many solutions running around the internet on how to change the submodules. One of the solution is deleting and adding the submodules on fresh. Else, The other solutions explains by editing .gitmoduels or config file from .git folder using a text editor and to do a sync and update.

Here is an good example on how to change the submodule using the GIT Bash commands successfully.
The steps involved are:

        1. List the details in .gitmodules file using GIT Bash command

$ git config --file=.gitmodules -l
                    This command  lists all the submodules present in the current repository with their paths, URL location and the branch which it is mapped in the repository.


        2. Edit the Submodule URL in .gitmodules file using GIT Bash command

              git config --file=.gitmodules submodule.Submod.url 
                                                                https://github.com/pavansn/GitSubmodules.git
                      This command will edit the URL of the submodule and will place it with the specified new URL repository. On using the command from step 1. It displays the changed URL(but the contents of Submodule are not updated)








        3. Edit the Submodule Branch in .gitmodules file using GIT Bash command

              git config --file=.gitmodules submodule.Submod.branch Developer1
                      This command will edit the Branch (Dev1) of the submodule and will place it in the specifified Branch (Developer1)  On using the command from step 1. It displays the changed branch(but the contents of Submodule are not updated)

        4. Sync and update the Submodule using GIT Bash commands
                
              git submodule sync
              $ git submodule update --init --recursive --remote
                      These commands will sync and update the submodule to the newly specified branch or URL successfully.







Summary:

------------------------------CMDs to edit and update the submodules----------------------------------

$  git config --file=.gitmodules -l
$ git config --file=.gitmodules submodule.Submod.url https://github.com/username/ABC.git $ git config --file=.gitmodules submodule.Submod.branch Development $ git submodule sync $ git submodule update --init --recursive --remote

------------------------------CMDs to edit and update the submodules----------------------------------

Comments

  1. Youre so cool! I dont suppose Ive read something like this before. So nice to seek out somebody with some unique thoughts on this subject. realy thanks for beginning this up. this web site is one thing that is wanted on the internet, someone with slightly originality. useful job for bringing something new to the web! play casino

    ReplyDelete
  2. Sap fico training institute in Noida

    Sap fico training institute in Noida - Webtrackker Technology is IT Company which is providing the web designing, development, mobile application, and sap installation, digital marketing service in Noida, India and out of India. Webtrackker is also providing the sap fico training in Noida with working trainers.


    WEBTRACKKER TECHNOLOGY (P) LTD.
    C - 67, sector- 63, Noida, India.
    F -1 Sector 3 (Near Sector 16 metro station) Noida, India.

    +91 - 8802820025
    0120-433-0760
    0120-4204716
    EMAIL: info@webtrackker.com
    Website: www.webtrackker.com

    ReplyDelete
  3. I really enjoyed your blog Thanks for sharing such an informative post.

    shuttering works

    ReplyDelete
  4. I really enjoyed your blog Thanks for sharing such an informative post.

    best seo company for increse your website traffic SSS digital Marketing

    ReplyDelete
  5. nice article post.keep updating us.We offer the most budget-friendly quotes on all your digital requirements. We are available to our clients when they lookout for any help or to clear queries.

    Best SEO Services in Chennai | digital marketing agencies in chennai | Best seo company in chennai | digital marketing consultants in chennai | Website designers in chennai

    ReplyDelete
  6. nice article post.keep updating us.We offer the most budget-friendly quotes on all your digital requirements. We are available to our clients when they lookout for any help or to clear queries.

    Best SEO Services in Chennai | digital marketing agencies in chennai | Best seo company in chennai | digital marketing consultants in chennai | Website designers in chennai

    ReplyDelete
  7. Such a nice article. This is one of the most amazing articles I have read so far. Really it was an awesome article. Looking for real active followers for instagram profile, then i would recommend to Buy instagram followers India

    ReplyDelete
  8. Well done dear, i have read your post and getting interesting facts. Its better to buy active and real followers, likes and location based traffic to gain online value so here are best website for Social Media Marketing Company in India


    If you want to Buy Real Instagram Followers Paytm than you can visit and talk with support direct. Keep posting more articles.

    ReplyDelete
  9. i dont know what was the reason for changing branch to devloper1

    ReplyDelete
  10. i am stuck at point where you are playing with branch,
    i get an error:
    fatal: Needed a single revision
    Unable to find current origin/developer1 revision in submodule path 'Submod'

    ReplyDelete
  11. 9and9 provides the best digital marketing services in Hyderabad and offers digital branding services to all our small and medium-size businesses

    ReplyDelete
  12. Many thanks for your kind invitation. I’ll join you.
    Would you like to play cards?
    Come to the party with me, please.
    See you soon...

    เล่นบาคาร่า

    คาสิโนออนไลน์

    คาสิโน

    แจกเครดิตฟรี ฝากถอนง่าย

    ReplyDelete
    Replies
    1. NDUW is a labor registration portal created by the Labor Department, Government of india. The registration of the unorganized workers (working class) of the state takes place on this portal.
      upbocw registration is provided by the Uttar Pradesh government

      Delete
  13. jan adhar card very usefull in rajsthan govt. All Process in Download See Now

    ReplyDelete
  14. Click:-https://cattlepetsdog.blogspot.com/
    Read australian cattle dog wesen.
    Click:-https://cattlepetsdog.blogspot.com/2022/01/australian-cattle-dog-wesen.html

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. Land stock positive agree various. Book perhaps no might model.trending-updates

    ReplyDelete

Post a Comment