mjeppesen
mjeppesen

Reputation: 1099

Git best way to fork a submodule already in a repository

I have a git submodule (a vim plugin from github) which is already inside a git repository, and has been for 10 commits or so.

I would now like to fork the submodule repo and make my own changes.

I think this will work ... but is it a bad way to do it?

  1. Fork the submodule on github.
  2. Edit my .gitmodules file in the main repo so it points to my forked repo on github
  3. git submodule sync
  4. git submodule update

Or will this lose some git history tracking information / is there a better way?

Upvotes: 1

Views: 256

Answers (1)

Colin Hebert
Colin Hebert

Reputation: 93167

This is how you're supposed to do it (maybe except git submodule update which in your case shouldn't do anything until you've done your own commits). You'll just have to remember to fetch from time to time changes from upstream if you want to keep your module up to date.

To do this part, just go inside your submodule, add an upstream remote toward the upstream repository and fetch upstream.

Upvotes: 3

Related Questions