Skip to content

Repository Management

neitsa edited this page Dec 26, 2016 · 5 revisions

We use Git subtree commands to handle the RemoteTech-Complete repository as it is composed of the other repositories in the RemoteTechnologiesGroup organisation.

Adding a new subtree

First we need to add a remote for the subtree. The command is:

$ git remote add <friendly_name> <repo_url>

Example with RemoteTech-Common:

Neitsa@Falcon /RemoteTech-Complete (develop)
$ git remote add RemoteTech-Common https://github.com/RemoteTechnologiesGroup/RemoteTech-Common.git

Next add the subtree to RemoteTech-Complete. The command is:

$ git subtree add --prefix=<location> <friendly_name> <branch> --squash

Where:

  • <location> is the location of the subtree inside RemoteTech-Common
  • <friendly_name> is the name of the repository used in the previous step
  • <branch> is the branch from which to get the code
  • --squash: Always use this option to avoid polluting the history of the repository containing the subtree(s)

Example:

Neitsa@Falcon /RemoteTech-Complete (develop)
$ git subtree add --prefix=src/RemoteTech-Common RemoteTech-Common develop --squash
git fetch RemoteTech-Common develop
From https://github.com/RemoteTechnologiesGroup/RemoteTech-Common
* branch            develop    -> FETCH_HEAD
Added dir 'src/RemoteTech-Common'

Note: If you have a problem while trying to add a new subtree:

Neitsa@Falcon RemoteTech/RemoteTech-Complete (develop)
$ git subtree add --prefix=src/RemoteTech-CommandHandler RemoteTech-CommandHandler develop --squash
Working tree has modifications.  Cannot add.
  1. Check the output of git status in case you have untracked files or files waiting to be committed.
  2. If the output of git status indicates a clean working directory state, try git diff-index HEAD.
  3. Takes proper action if the above command (git diff-index HEAD) indicates a non clean working directory.
  4. If both git status and git diff-index HEAD doesn't output something that needs immediate action, consider re-checking out the branch you are on:
    • git checkout <branch>

Updating a subtree

If you need to update the subtree in RemoteTech-Complete, use the subtree pull command:

Neitsa@Falcon /RemoteTech-Complete (develop)
$ git subtree pull --prefix=<location> <friendly_name> <branch> --squash

Example:

Neitsa@Falcon /RemoteTech-Complete (develop)
$ git subtree pull --prefix=src/RemoteTech-Common RemoteTech-Common develop --squash

Updating the subtrees of the RemoteTech-Completerepository can be done with the scripts/update_subtrees.sh script in this repo (see here).

Clone this wiki locally