I know that there are questions like this, but that’s not what I’m asking.
I also know that:
git checkout tag-name:
- Detaches you from the branch. (i.e. moves
HEADpointer, keepsBRANCHpointer)
git reset --hard tag-name:
- Does not detach you from the branch, but makes the previous commits to become “dangling”. (i.e. moves both
HEADandBRANCHpointers)
I wonder which one makes more sense for updating to a tag, i.e. should a production be reseted or checked out. I know that a garbage collector may run, removing dangling commits, but then again, if the production is always “pulled” before the process of updating to a tag, I see nothing bad there.
Should a production update to a tag with reset or checkout, considering that a pull is always done prior to this update call?
Your production install should be checking out a tag.
Think of it this way: your production install is read-only.
git reset --hard tag-namewill modify the currently checked out branch.Alternatively
It’s common practice that in addition to creating a tag, you have one branch which is simply the latest release. In which case you’d e.g. merge to master and create a tag from there; and on your production installs you’d update simply with git pull (on master).