How can a Git tag be aligned with the formatted PDF using gitinfo2?

The main assumption is that abc.pdf is being tracked by git.

Here is a list of command line steps, that keeps the release number up to date (this assumes that abc.pdf has been committed at some point previously)

(start with clean repo, make changes to abc.tex and compile)

git add abc.tex
git commit -m "my commit message goes here"
git tag -a 1.34
git checkout abc.pdf
pdflatex  abc
git add abc.pdf
git commit -m "updated release number in pdf"

Here is the file I have used for abc.tex

\documentclass{article}
\usepackage[mark,grumpy]{gitinfo2}

% gitinfo2 settings
\renewcommand{\gitMark}{Release: \gitRel}

\begin{document}
hello world
\end{document}

One reason your release tag might not be as you intend could be because it isn't being picked up by

RELTAG=$(git describe --tags --long --always --dirty='-*' --match '[0-9]*.*' 2>/dev/null)` in the `.git/hooks/post-.*

files. If your tag starts with anything other than a number, then you need to change the --match part accordingly. For example, if your tag starts with a V, as in V3.2.2, then you might use

RELTAG=$(git describe --tags --long --always --dirty='-*' --match 'V[0-9]*.*' 2>/dev/null)` in the `.git/hooks/post-.*

Thanks for the support cmhughes!

I will wrap it up:

My question is a question related to git. gitinfo2 is supposed to work like this - that's fine for me.

Starting from here:

Starting point

we can

  • move the tag, as described in this post by doing

    git tag -fa 1.34

  • or merge the commits (rebase) as described in this post.

    git rebase -i HEAD~2

and than change in the upcoming dialog (looks something like this):

pick 2840179 Changing abc.tex
pick 00d844f Adding abc.pdf

# Rebase 8c99d54..00d844f onto 8c99d54
#
....

the second pick (pointing to the last commit) into a squash.

This ends up in a (maybe) more nice history. However, we have to retag afterwards as well with git tag -fa 1.34. Otherwise we loose the tag...:

enter image descripand than change the second and than change the second tion here

Thomas

Tags:

Git

Gitinfo