Pregunta

I just learned how to revert a branch. That works fine. The thing is, I tagged the master's commits and I plan to use the git describe command to create deployments based on the latest tag. Reverting a commit creates a new commit, so the git describe command outputs the tag with the commit ammend, like so:

Before:

git describe
1-2-0

After revert 'back' to this commit:

git describe
1-2-0-1ga99ae04

Is there a way to overcome this? Or should I get the latest tag differently?

¿Fue útil?

Solución

Just to be clear. You dont really revert "back". Say you have the following history.

A<--B<--C<--D
            |
        (tag:1-2-0)

Now say you revert C. This is what happens.

A<--B<--C<--D<--E
            |
        (tag:1-2-0)

As you can see you have moved forward in history. If this tag has already been released, then you probably want to consider this a "hotfix", and tag again as 1-2-0-1, or something along those lines. Not sure what your version number scheme is, so obviously just work hotfixes into your process.

Considering this change a hotfix would result in this.

           (tag:1-2-0-1)
                | 
A<--B<--C<--D<--E
            |
        (tag:1-2-0)

However if you have not released or even pushed this tag up to the remote, and just want to move the tag to point to E, then you can do this two ways. The easy to remember way is to delete the tag and recreate it.

git tag -d 1-2-0
git tag 1-2-0 E

The shorter, faster, but infinitely less friendly way to change the tag without deleting it would be to use update-ref.

git update-ref refs/tags/1-2-0 E

In the odd case that you have pushed the tag up and want to remove it from the remote, use the following syntax.

git push <remote> :1-2-0

Assuming origin is your remote.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top