2

I have a bare git repo set up which runs a post-update hook as follows:

GIT_WORK_TREE=/path/to/code git checkout -f

This works well when pushing code to, for example, a webserver. I can work on code, and when I'm finished, updating the webserver is a simple git push live master away.

However, I don't know how to rollback to, for example, a specific tag. Usually that can be done with git checkout TAG, but when I attempt to checkout a tag (e.g. GIT_WORK_TREE=/path/to/code git checkout -f TAG), git responds:

error: pathspec 'TAG' did not match any file(s) known to git

Any ideas on how to checkout a tag on a remote working tree?

JoBu1324
  • 7,751
  • 6
  • 44
  • 61

1 Answers1

2

To checkout a tag on the remote side, you need to push it first:

git push --tags

As mentioned in "With GitHub how do I push all branches when adding an existing repo?", even git push --all wouldn't push your tags, only all refs under refs/heads/.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250