Exercise - Tags

Tips

  • Create tags
    • git tag 'my-first-tag'
    • optionally a revision can be specified (default: HEAD)
  • Simple tags are just names for commits
  • For releases, one uses annotated tags, which carry a description and metadata. The following options are helpful:
    • -a ensures the creation of an annotated tag.
    • -m 'And here comes text' for the description
  • Tags are not automatically transferred on push.
    • You can either specify individual tags, e.g. git push origin v1.0 v1.1
    • git push --tags transfers tags
  • Tags are usually transferred on pull. With --tags you can have all tags transferred.
  • Recommendation: Tags that you share with others (push), should not be changed anymore. Git warns before transferring changed tags. If necessary, you can force the transfer with -f.

Setup

Step 0 - START

$ cd mein-klon


Step 1 - Create tags

Start in directory git-uebungen/aufgaben/<unknown>.

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).

Step 2 - Fetch tags

Start in directory git-uebungen/aufgaben/<unknown>.

Simply by pull.

Step 3 - Push tags

Start in directory git-uebungen/aufgaben/<unknown>.

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

Step 4 - Manipulate

Start in directory git-uebungen/aufgaben/<unknown>.

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 $ cd ..


To the solution

To the overview