¿Cómo restaurar y confirmar la versión anterior en git?

Lets suppose git log shows versions:

fff
...
ccc
bbb
aaa

How to get back to version bbb and commit it without destroying history. So that git log would show:

bbb*
fff
...
ccc
bbb
aaa

preguntado el 10 de marzo de 12 a las 09:03

git reset --hard bbb is not enough because it destroys history. -

git checkout bbb is not enough because it does not commit. -

2 Respuestas

You want to try doing git revert:

git revert -n  fff eee ddd ccc

And of course, you can use notations like master~4..master etc.

respondido 10 mar '12, 09:03

I'm looking for an easier way than listing 15 or so commit hashes. I don't like counting the number of commits either. Too easy to make a mistake. - Stancell

@Stancell - You can use the notation like I mentioned in the last line. - manojlds

Yes, it would work. It would be even better if I could do something like git revert -n bbb..master. Suppose every new year I have to bring new year version of web page ar logo. Counting hundreds of commits is not an option :) - Stancell

@Stancell - Why don't you do some research? You can do bbb..master. That is why I said etc. - manojlds

I tried it before responding. git revert -n 510862f12f857c98ae..master resultados en fatal: Cannot find '510862f12f857c98ae..master'. ¿Funciona para ti? - Stancell

creo que usted podría utilizado git reset --hard, if you follow it with a git reset --soft back to where you were:

git reset --hard bbb
git reset --soft fff
git commit

respondido 10 mar '12, 10:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.