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. 3d Animation Course training Classes

    Best institute for 3d Animation and Multimedia

    Best institute for 3d Animation Course training Classes in Noida- webtrackker Is providing the 3d Animation and Multimedia training in noida with 100% placement supports. for more call - 8802820025.

    3D Animation Training in Noida

    Company Address:

    Webtrackker Technology

    C- 67, Sector- 63, Noida

    Phone: 01204330760, 8802820025

    Email: info@webtrackker.com

    Website: http://webtrackker.com/Best-institute-3dAnimation-Multimedia-Course-training-Classes-in-Noida.php


    Our courses:
    3D Animation and Multimedia Training in Noida.
    3d Multimedia Institute in Noida.
    Animation and Multimedia Training in Noida.
    Animation and Multimedia Training institute in Noida .
    Multimedia Training institute in Noida.
    Multimedia Training classes in Noida.
    3D Animation Training in Noida.
    3D Animation Training institute in Noida.

    ReplyDelete
  3. Webtrackker Technology is IT Company and also providing the Solidwork
    training in Noida at running project by the real time working trainers.
    If you are looking for the Best Solidwork training institute in Noida
    then you can contact to webtrackker technology.
    Webtrackker Technology
    C- 67, Sector- 63 (Noida)
    Phone: 0120-4330760, 8802820025
    8802820025
    Solidwork training institute in Noida

    ReplyDelete
  4. 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

Post a Comment