Commands | +Description | +Example | +
---|---|---|
mkdir <name> | +Creation of an empty folder for the base component named "name" | ++ + $ mkdir basis + |
cd <name> | +Switching into the base component repository. | ++ + $ cd basis | +
git init | +Creation of a new Git Repository + | + + $ git init + Initialized empty Git repository in + /home/norbert/basis/.git/ + |
+
git submodule add <repo> <path> | +Adding submodules. This command is repeated for each submodule. | ++ + $ git submodule add https://bitbucket.org/nhjschulz/subm_a.git submod/a + Cloning into '/home/norbert/basis/submod/a'... + remote: Enumerating objects: 36, done. + remote: Counting objects: 100% (36/36), done. + remote: Compressing objects: 100% (26/26), done. + remote: Total 36 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0) + Receiving objects: 100% (36/36), done. + | +
git status | +Check the current status. Adding submodules resulted in changes that
+need to be checked in. A directory got created for each submodule and +the .gitmodules file was created or extended. |
+
+
+ $ git status
+ On branch master
+
+ No commits yet
+
+ Changes to be committed:
+ (use "git rm --cached |
+
git commit -a -m "<msg>" | +Check-in and commit of the modified submodule definitions. | ++ + $ git commit -a -m "Added Submodule https://bitbucket.org/nhjschulz/subm_a.git" + [master (root-commit) 1054429] Added Submodule https://bitbucket.org/nhjschulz/subm_a.git + 2 files changed, 4 insertions(+) + create mode 100644 .gitmodules + create mode 160000 submod/a + | +
Commands | +Description | +Example | +
---|---|---|
git clone <url>--recurse-submodules | +Initial cloning of a repository including all submodules. This is +achieved by using the "--recurse-submodules" option. + +Use the following commands if "--recurse-submodules" has been +forgotten during clone. This option is primarily a convenience to do +this automatically: +$ git submodule init '$ git submodule update +Cloning into '/home/norbert/submod_cfgmgmt/base/subm/a'... |
++ + $ git clone https://bitbucket.org/nhjschulz/base.git --recurse-submodules + Cloning into 'base'... + remote: Enumerating objects: 34, done. + remote: Counting objects: 100% (34/34), done. + remote: Compressing objects: 100% (31/31), done. + remote: Total 34 (delta 9), reused 0 (delta 0), pack-reused 0 (from 0) + Receiving objects: 100% (34/34), done. + Resolving deltas: 100% (9/9), done. + Submodule 'subm/a' (https://bitbucket.org/nhjschulz/subm_a.git) registered for path 'subm/a' + Submodule 'subm/b' (https://bitbucket.org/nhjschulz/subm_b.git) registered for path 'subm/b' + Cloning into '/home/norbert/submod_cfgmgmt/base/subm/a'... + remote: Enumerating objects: 36, done. + remote: Counting objects: 100% (36/36), done. + remote: Compressing objects: 100% (26/26), done. + remote: Total 36 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0) + Receiving objects: 100% (36/36), done. + Cloning into '/home/norbert/submod_cfgmgmt/base/subm/b'... + remote: Enumerating objects: 29, done. + remote: Counting objects: 100% (29/29), done. + remote: Compressing objects: 100% (21/21), done. + remote: Total 29 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0) + Receiving objects: 100% (29/29), done. + Resolving deltas: 100% (1/1), done. + Submodule path 'subm/a': checked out 'c776b6f3ae2e58de0b1dd05302b48004b23492c5' + Submodule path 'subm/b': checked out 'ee28a60fabf10470991d83615021650987885c71' ' + | +
Commands | +Description | +Example | +
---|---|---|
git pull | +The base repository is updated by a pull. It updates the base +component working copy, but does not touch the submodules yet. | ++ + $ git pull + remote: Enumerating objects: 1, done. + remote: Counting objects: 100% (1/1), done. + remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0) + Unpacking objects: 100% (1/1), 149 bytes | 149.00 KiB/s, done. | +
git submodule update --init --recursive --remote | +The submodules are updated to the commits of the branch HEADs as +defined by the .gitmodules file. | ++ + $ git submodule update --init --recursive --remote + Submodule path 'subm/a': checked out'382a28f0d54609483a6843c5f13d879868b7b809' + | +
Commands | +Description | +Example | +
---|---|---|
git checkout <branch> | +Set the base component to the target branch (integration or +development branch). | ++ + $ git checkout development + Switched to branch 'development' + Your branch is up to date with 'origin/development'. + | +
git submodule set-branch --branch <branch> <module> | +Create a branch entry for a submodule in .gitmodules. This command +is repeated for all submodules whose branch is to be switched. | ++ + $ git submodule set-branch --branch development subm/a + |
git diff | +With git diff you can see that the branch of the +submodule has been changed inside .gitmodules. + +```{note} +Only the entry in the .gitmodules file has been adjusted. The +submodule versions in the working copy have not (yet) changed. +``` + + |
+
+
+ $ git diff
+ diff --git a/.gitmodules b/.gitmodules
+ index 7cb7f77..01af15d 100644
+ --- a/.gitmodules
+ +++ b/.gitmodules
+ @@ -1,7 +1,7 @@
+ [submodule "subm/a"]
+ path = subm/a
+ url = https://bitbucket.org/nhjschulz/subm_a.git
+ - branch = release/v0.1.0 + + branch = development + [submodule "subm/b"] + path = subm/b + url = https://bitbucket.org/nhjschulz/subm_b.git + |
git submodule update --recursive --remote | +Apply the changes in .gitmodules to the submodules. This sets the +commit reference in the index to the HEAD of the branch and checks it +out. The "--remote" causes changes from the upstream submodule repository +to be fetched first, and then switch to the HEAD of the branches. | ++ + $ git submodule update --recursive --remote + Submodule path 'subm/a': checked out '382a28f0d54609483a6843c5f13d879868b7b809' + | +
git status | +A status check shows that we need to check in the changes to +.gitmodules and the and the module's directory. At least .gitmodules and +all changed submodule folders must be checked in. | +
+
+ $ git status
+ On branch main
+ Your branch is up to date with 'origin/main'.
+
+ Changes not staged for commit:
+ (use "git add |
+
git commit -a -m "<msg>" | +Check in of the submodule branch changes. | ++ + $ git commit -a -m "Changed Submodule A to development branch" + [main d695de1] Changed Submodule A to development branch + 2 files changed, 2 insertions(+), 2 deletions(-) + | +
Commands | +Description | +Example | +
---|---|---|
git checkout <version> | +Check out the desired version in the base component. | ++ + $ git checkout release/v0.1.0 + Switched to branch 'release/v0.1.0' + Your branch is up to date with 'origin/release/v0.1.0'. + | +
cd <submodule> | +Switch into the component you want to edit | ++ + $ cd subm/a + |
git status +git log <ID> -n 1 |
+Check the status of the component. As expected, we are on a +commit with no branch context. +The log command shows that this commit belongs to the V0.1.0 tag . +Since we want to add a feature to this version, we create a new branch +for it in the next step. + |
++ + $ git status + HEAD detached at c776b6f + nothing to commit, working tree clean + + $ git log c776b6f -n 1 + commit c776b6f3ae2e58de0b1dd05302b48004b23492c5 (HEAD, tag: V0.1.0,origin/release/v0.1.0, release/v0.1.0) + Author: Norbert Schulz <github@schulznorbert.de + Date: Mon Sep 30 16:23:33 2024 +0200 + + Update 8 on dev branch + |
git checkout -b <name> <tag> | +Create a new branch to edit/update the component. Committing and +pulling of changes is possible after this step. | ++ + $ git checkout -b feature/new V0.1.0 + Switched to a new branch 'feature/new' + + $ git status + On branch feature/new + nothing to commit, working tree clean + | +
<edit> | +"Featue New" gets implemented here. | ++ + $ echo "Feature/new is here" > README.md (http://README.md) + | +
git commit -a -m "<msg>" | +Check-in of the changes. | ++ + $ git commit -a -m "Added Feature New" + [feature/new 4cb7e76] Added Feature New + 1 file changed, 1 insertion(+), 1 deletion(-) + | +
Commands | +Description | +Example | +
---|---|---|
cd <submod-dir> | +Switch to the submodule to be versioned, | ++ + $ cd subm/a + |
git fetch +git log |
+Determine the commit hash to be versioned. This step is optional if +the hash is already known. The "git fetch" ensures that all existing +hashes are also known in the local repository. | +
+
+ $ git fetch
+ $ git log
+ commit 382a28f0d54609483a6843c5f13d879868b7b809 (HEAD, origin/development)
+ Author: Norbert Schulz |
+
git tag -m "version <version>" +<version_tag_name> <hash> | +Assign a version tag for the desired commit. In the example it is +V2.0.0. | ++ + $ git tag -m "Release V2.0.0" V2.0.0 382a28f0d54609483a6843c5f13d879868b7b809 + |
git branch release/<version> +<version_tag_name> | +Create a version branch for the tag you just created. | ++ + git branch release/v2.0.0 V2.0.0 + |
git push --set-upstream origin +<local_branch_name>:<remote_branch_name> | +Make the new branch known in the "upstream" repository "origin". The +last parameter contains the branch name twice, separated by a colon. The +name on the left is the banch name in the local repository. The right +name will be the new branch in the "upstream" repository. | ++ + $ git push --set-upstream origin release/v2.0.0:release/v2.0.0 + To https://bitbucket.org/nhjschulz/subm_a.git + (https://bitbucket.org/nhjschulz/subm_a.git) + * [new branch] release/v2.0.0 -> release/v2.0.0 + branch 'release/v2.0.0' set up to track 'origin/release/v2.0.0'. + | +
git push origin tag <version_tag_name> | +Make the release tag known to the "upstream" origin repository. A +"normal" push does not transfer tags. | ++ + $ git push origin tag V2.0.0 + Enumerating objects: 1, done.Counting objects: 100% (1/1), done. + Writing objects: 100% (1/1), 169 bytes | 169.00 KiB/s, done. + Total 1 (delta 0), reused 0 (delta 0), pack-reused0 + To https://bitbucket.org/nhjschulz/subm_a.git + * [new tag] V2.0.0 + | +
Commands | +Description | +Example | +
---|---|---|
git checkout <Integrations Branch> | +In the base repository, the integration branch is checked out. | ++ + $ git checkout integration + Switched to branch 'integration' + | +
<update der Submodule Versionen> | +On the Integrations branch, the .gitmodules file is edited. The +"branch" entries for components with new versions are adjusted. In the +example, the version of the subm/a component has been increased | ++ + $ vi .gitmodules$ git diff + diff --git a/.gitmodules b/.gitmodules + index 7cb7f77..62afcf6 100644 + --- a/.gitmodules + +++ b/.gitmodules + @@ -1,7 +1,7 @@ + [submodule "subm/a"] + path = subm/a + url = https://bitbucket.org/nhjschulz/subm_a.git + - branch = release/v0.1.0 + + branch = release/v2.0.0 + [submodule "subm/b"] + path = subm/b + url = https://bitbucket.org/nhjschulz/subm_b.git + | +
$ git submodule update --init --remote --recursive | +The working copy of the integration branch is updated to the new +component version. The "git status" shows the changes in the submodules +(only subm/a" has changed here). +A integrator may now perform smoke tests on this configuration and +check it in if successful. |
+
+
+ $ git submodule update --init --remote --recursive
+ Submodule path 'subm/a': checked out '382a28f0d54609483a6843c5f13d879868b7b809'
+
+ $ git status
+ On branch integration
+ Changes not staged for commit:
+ (use "git add |
+
git commit -a -m "<msg>" +git push |
+The changes of the integration branch are checked into git and
+pushed. +Further tests can now be run on the integration branch, or a new version +can be created right away for testers to work with. |
++ + $ git commit -a -m "Preparing Release v2.0.0" + [integration 3b811e2] Preparing Release v2.0.0 + 2 files changed, 2 insertions(+), 2 deletions(-) + + $ git push + Enumerating objects: 7, done. + Counting objects: 100% (7/7), done. + Delta compression using up to 22 threads + Compressing objects: 100% (4/4), done. + Writing objects: 100% (4/4), 391 bytes | 391.00 KiB/s, done. + Total 4 (delta 2), reused 0 (delta 0), pack-reused 0 + | +
git tag -m "Created version <version>" +<tag_version> +git push origin tag <tag_version> |
+A new base component version is created by setting a tag. Unlike +submodules, no branch necessarily has to be created here. The base +component is not included in .submodules. | ++ + $ git tag -m "Created version V2.0.0" V2.0.0 + + $ git push origin tag V2.0.0 + * [new tag] V2.0.0 -> V2.0.0 + | +
git branch release/<version> <tag_version> +git push --set-upstream origin +<local_branch_name>:<remote_branch_name> |
+Optional: Create a release branch for the new version: | ++ + $ git branch release/v2.0.0 V2.0.0 + + $ git push --set-upstream origin release/v2.0.0:release/v2.0.0 + * [new branch] release/v2.0.0 ->; release/v2.0.0 + branch 'release/v2.0.0' set up to track 'origin/release/v2.0.0'. + |