Git - Tagging

From Training Material
Jump to navigation Jump to search


Tagging

  • Tag is not a copy of the repo
  • Tag doesn't create a revision
  • Tag is just an another name for a revision (apart of SHA1)
git tag tagname # creates  tag from HEAD of the current branch
git tag # shows all tags
git tag tagname -m “message”
git tag tagname 6544ce
git tag -l v1

Lightweight vs Object Tags

Lightweight Object Tags
git tag v1.1.0 1b2e1d63n
git push --tags (optional presentation with cloning)  
  • “a branch that never moves”
  • cannot include a comment
  • cannot be signed cryptographically
git tag -a stable-1 1b2e1d63ff

  • If one of -a, -s, or -u <key-id> options is passed
  • Needs to contain a message (can be empty)
  • can tag any object (not only commit object)

Exercise (Tagging)

  • Tag the HEAD as v1.0
  • Add another line to a file
echo second line >> afile.txt
  • Commit changes
  • Tag the commit as v1.1
  • Add third line and commit
echo third line >> afile
  • Show difference (use git diff) between HEAD and the tag v1.0
  • List all the tags