0

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 
2
  • git reset --hard bbb is not enough because it destroys history. Commented Mar 10, 2012 at 9:28
  • git checkout bbb is not enough because it does not commit. Commented Mar 10, 2012 at 9:31

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

7 Comments

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 - You can use the notation like I mentioned in the last line.
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 - Why don't you do some research? You can do bbb..master. That is why I said etc.
I tried it before responding. git revert -n 510862f12f857c98ae..master results in fatal: Cannot find '510862f12f857c98ae..master'. Does it work for you?
|
0

I think you could use 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 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.