I want to maintain a directory which will be always up to date with the latest tag from a git repository. I tried this solution, however, if I do it once, I end up in a detached HEAD state, and if I do git describe --tags
, newer tags do not appear here any more. Is there a better way to do it, or am I missing something?
Asked
Active
Viewed 505 times
0

machaerus
- 749
- 1
- 6
- 20
2 Answers
0
checkout of tags will always end up in detached HEAD state because a tag shouldn't be moved, even if you commit.

eftshift0
- 26,375
- 3
- 36
- 60
-
I see, but I need something like a read-only copy of a repo, always synced with the latest tag. How can I achieve this? – machaerus May 26 '17 at 14:09
-
In order to checkout the "latest tag" and assuming that git tag won't show them in chronological order, you might analyze each one of the tags and see which one of them is the latest and check it out. If you want to know how t analyze when a commit was done to do it in a bash script, I would take a look at the commit time from the revision itself (use git cat-file -p
). Then it's a matter of doing a while read cycle analyzing each tag... and then it becomes a "bash" question, not a git question. – eftshift0 May 26 '17 at 14:14 -
the problem is, if I'm in detached HEAD already, it won't list any new tags at all: only the one on which I checked out previously. – machaerus May 26 '17 at 16:07
-
1being in detached HEAD state has no influence on showing new tags. I guess you are missing a fetch? – eftshift0 May 26 '17 at 16:08
0
Actually what you want is more like the behaviour of a branch instead of tags.
You can maintain a branch where you merge in every new tag that is created.
Then you check out this branch and regularly simply git pull
from remote.
Btw. to see new tags, you have first to
git fetch
It doesn't matter what you have checked out (like @Edmundo already said).
When you execute git describe --tags
the local mirror of the repo is queried. No network traffic occurs. Two update your local mirror you have to fit fetch
.

Manuel Schmidt
- 2,178
- 2
- 15
- 19