简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM