20

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 HEAD pointer, keeps BRANCH pointer)

git reset --hard tag-name:

  • Does not detach you from the branch, but makes the previous commits to become "dangling". (i.e. moves both HEAD and BRANCH pointers)

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?

Community
  • 1
  • 1
Tower
  • 98,741
  • 129
  • 357
  • 507

1 Answers1

17

I wonder which one makes more sense for updating to a tag

Your production install should be checking out a tag.

Think of it this way: your production install is read-only. git reset --hard tag-name will 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).

AD7six
  • 63,116
  • 12
  • 91
  • 123