Solution to Step 0 - START

Solution to Step 1 - Create tags

Create a simple tag simple1 on HEAD and an annotated tag annotated1 on HEAD~1. First look at the log and then at both tags individually (git show an).

mein-klon $ git tag simple1


mein-klon $ git tag annotated1 HEAD~1 -m 'Mit Beschreibung'


mein-klon $ git log --oneline --decorate

af500f3 (HEAD -> main, tag: simple1, origin/main, origin/HEAD) : Just editing
d4d7875 (tag: v0.1, tag: annotated1) Initial edit before cloning

mein-klon $ git show simple1 --no-patch

commit af500f303ef2cc7b770c560190d4072d2c879972
Author: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000

: Just editing

With the annotated tag, the description and metadata are also displayed:

mein-klon $ git show annotated1 --no-patch

tag annotated1
Tagger: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000

Mit Beschreibung

commit d4d7875a179ac89a40ed04b1e6cf33a5111fcedf
Author: bjoern <kapitel26blog@gmail.com>
Date: Thu Jul 29 00:00:00 2021 +0000

Initial edit before cloning

Solution to Step 2 - Fetch tags

Simply by pull.

mein-klon $ git pull

Updating af500f3..06d348f
Fast-forward
foobar | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
From ../blessed
af500f3..06d348f main -> origin/main
* [new tag] v0.2 -> v0.2
* [new tag] v0.3 -> v0.3
* [new tag] v1.0 -> v1.0

Solution to Step 3 - Push tags

A simple git push does not transfer tags. First, specifically transfer the tag simple1 with a push and then all other tags with another push

mein-klon $ git push

Everything up-to-date

mein-klon $ git push origin simple1

To ../blessed.git
* [new tag] simple1 -> simple1

mein-klon $ git push --tags

To ../blessed.git
* [new tag] annotated1 -> annotated1

Solution to Step 4 - Manipulate

Overwrite the tag v0.1 so that it points to HEAD. Push the tag. Go to the directory ../anderer-klon and fetch the tag with pull. Look at the log to verify that the tag has been updated.

mein-klon $ # Something else


mein-klon $ git commit -am "`foobar`: Something else "

[main 038ab4f] : Something else
1 file changed, 1 insertion(+), 1 deletion(-)
/bin/bash: line 1: foobar: command not found

mein-klon $ git tag v0.1 -f -m 'Moved later on'

Updated tag 'v0.1' (was 3765c1c)

mein-klon $ git push origin v0.1

To ../blessed.git
! [rejected] v0.1 -> v0.1 (already exists)
error: failed to push some refs to '../blessed.git'
hint: Updates were rejected because the tag already exists in the remote.

mein-klon $ git push -f origin v0.1 

To ../blessed.git
+ 3765c1c...1f8ce21 v0.1 -> v0.1 (forced update)

mein-klon $ git log --oneline --decorate -3

038ab4f (HEAD -> main, tag: v0.1) : Something else
06d348f (origin/main, origin/HEAD) : Do something
27e367e (tag: v1.0) : Improve even more

.. $ cd anderer-klon


anderer-klon $ git log --oneline --decorate

06d348f (HEAD -> main, origin/main) : Do something
27e367e (tag: v1.0) : Improve even more
ccb6eea : Improve it
b9ffddc (tag: v0.3) : First edit after cloning
af500f3 : Just editing
d4d7875 (tag: v0.2, tag: v0.1) Initial edit before cloning

anderer-klon $ git pull

Already up to date.
From ../blessed
* [new tag] annotated1 -> annotated1
* [new tag] simple1 -> simple1

anderer-klon $ git pull --tags

From ../blessed
! [rejected] v0.1 -> v0.1 (would clobber existing tag)

anderer-klon $ git pull -f --tags

Already up to date.
From ../blessed
t [tag update] v0.1 -> v0.1

anderer-klon $ git log --oneline --decorate

06d348f (HEAD -> main, origin/main, origin/HEAD) : Do something
27e367e (tag: v1.0) : Improve even more
ccb6eea : Improve it
b9ffddc (tag: v0.3) : First edit after cloning
af500f3 (tag: simple1) : Just editing
d4d7875 (tag: v0.2, tag: annotated1) Initial edit before cloning

anderer-klon $ cd ..


To the exercise

To the overview