Skip to content

Working with Transforms as a Submodule

zsmi edited this page Sep 1, 2015 · 4 revisions

Adding the Transforms project as a Submodule

This project is meant to be used as a submodule to other CC projects. Run the following commands in the project directory where you want the transforms submodule to be created.

git submodule add https://github.com/commoncriteria/transforms.git
git add transforms
git commit -m "Added the Transforms submodule to the project"
git push

Pull the latest upstream transforms changes

To pull the latest upstream changes from the transform project run the following command from the top level directory of the git project containing the transforms submodule.

git submodule update --remote transforms

Note: This command will put your transforms directory in a detached HEAD state. If you plan on making changes to the transforms project from this directory you will first need to checkout a branch by running git checkout master

Pulling the latest transforms version committed to your project

The below command will make sure you have the latest version of the transforms repository that has been committed to your project.

git submodule update

Note: This command will put your transforms directory in a detached HEAD state. If you plan on making changes to the transforms project from this directory you will first need to checkout a branch by running git checkout master

Make changes to a submodule

First make sure you are on a branch within the submodule directory and up to date with the upstream version of the transforms submodule.

git checkout master
git submodule update --remote --merge

Now you can make changes within the transforms directory as if it's a normal git project. If you then want those changes to be applied to the parent project for others to use then you must change into the parent directory and run the following commands:

git add transforms
git commit -m 'Updated to new version of transforms submodule'
git push

Pushing new updates to transforms submodule and parent project

If you made changes to both the transforms submodule and the parent project and would like to push them at the same time you can run the following command from the project parent directory:

git push --recurse-submodules=on-demand

Troubleshooting

Committed to a detached HEAD

If you accidentally forgot to checkout a branch within the transforms directory and committed your changes you can run the below commands to merge your changes into the master branch. The commit number can be obtained by running git log from within the transforms directory.

git checkout master
git branch new_branch <commit number>
git merge new_branch
git branch -d new_branch
git push

Forgot to clone with repository with --recursive/Transforms directory is empty

Run the following command from the parent project directory:

git submodule init

These commands were adapted from the git-scm book.