365Git

  1. Search
  2. About
  3. Subscribe
  4. Archive
  5. Random

365Git

Regular small snippets and workflows for Git

My original plan of a post everyday turned out to be unrealistic, but I'll carry on posting as regularly as I can.

Find me @abizern on twitter if you have anything you'd like me to cover.

Older
  • Changing The URL Of An Upstream Submodule Repository

    Just a short one today.

    Say you have a repository that contains a submodule. But, for whatever reason, you want to change the URL that the submodule points to. This could be because that repo moved, or changed it’s name. Or maybe you’ve forked that repository and you want to use your fork as a submodule.

    All you need to do is to change the URL in the “.gitmodules” file (I wrote about doing this in my last post). Now, all you need to do is to run the command from the top level of the repository:

    git submodule sync
    

    This will update the local repository settings in “.git/config”.

    Note

    If you have more than one submodule, this will update all the submodules in “.git/config” the the URLs in “.gitmodules”. If you’ve set up your local repository with custom URLs (again, which I wrote about last time), this might not be what you want. You can choose to update submodule explicitly with:

    git submodule sync -- name
    

    which will only sync the repository called “name”, which you can get from the “.gitmodule” file in the “Submodule” section. Be mindful of the spaces before and after --.

    Posted on November 11, 2011 with 1 note ()

    1. 365git posted this

Field Notes Theme. Designed by Manasto Jones. Powered by Tumblr.