DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Git Submodule


Git submodule as Meteor package

We have a parent (container) Meteor application "niufour", now we want to add a new package "nf-search" to niufour.

Make sure if packages/ has been added into .gitignore.

Push the nf-search (outside of niufour folder) to remote repo, here we use a Phabricator server, with address .

Under the root of niufour, run:

git submodule add <remote-repo-url> packages/nf-search

While "packages/" is always in niufour/.gitignore, you should add module with:

git submodule add -f <remote-repo-url> packages/nf-search

The common form is: git submodule add <remote-repo-url> <local-path>, where the is where you want to put your submodule.

To add it into the niufour package list, add nfcommerce:nf-search into file /.meteor/packages.

After your partner push new codes into the repo, run commands below to synchronize:

git pull origin develop
git submodule update --init --recursive

Use git submodule status to list current commit of each subpackage.

Keep demo state in parent project

A demo need both codes and data at the exact state of the verified time. So if your project has not submodules, use commit and tag to record the demo state.

Otherwise, you can use commits in parent project to record demo state. In the example above, suppose niufour has another submodule "nf-core". In the development process, commit on "develop" branch in each submodule, without commit on niufour. Only when PM (project manager) verified the demo, and all developers have committed and pushed in each submodule, PM commits, tags and pushes in parent project by himself:

cd /path/to/niufour
git add -A
git commit -m "this is for demo of 2015.11.04"
git tag "demo-2015.11.04"
git push origin develop

Then pm dump the database (mongodump for MongoDB) to a folder with the same name of the tag name (here it's "demo-2015.11.04").

At the demo day, the PM restore the data into a new database (mongorestore for example), then run commands below to restore the codes for demo:

git clone <url-of-niufour>
git checkout demo-2015.11.04
git submodule init
git submodule update

Note: To demonstrate the usage of git submodule, use example in "Git权威指南", 23.1 ~ 23.3, by 蒋鑫.



Published

Oct 25, 2015

Last Updated

Oct 25, 2015

Category

Tech

Tags

  • git 36
  • submodule 3

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor