This is my requirement:
I have a -> b -> c (HEAD)
.
I am adding a new commit d
. Now, it becomes a -> b -> c -> d(HEAD)
.
Now, I want to revert to c
(that is, undoing all changes that were made in d
) and make an additional change and form e
. The tree should look like a -> b-> c -> d -> e(HEAD)
. NOTE: I must not lose the d
history. I must revert it and add new changes to e
.
UPDATE:
I can explain with a better example. Let's say I have a->b->c(HEAD)
, here c
is the primary or main commit. I'm trying to automate with a script.
Initial Step: I start with git checkout <SHA1 of c>
, tree looks like: a->b->c(DETACHED HEAD)
My Real query starts from here:
- I modify few files (I don't add any new files) and add a new commit
d
. So tree should look like:a->b->c->d(HEAD)
- I revert changes in #1 by running Initial Step and modify other files (again, I don't add any new files) and add a new commit
e
. So tree should look like:a->b->c->d->e(HEAD)
NOTE: Here e
= revert of commit d
+ new changes to c
. I can't blindly use git revert HEAD
since c
is considered to be the primary commit. I was thinking I could use git stash
and git stash pop
to remove old changes and insert new changes. Can I do something like git checkout stash
?
In short: I'm trying to fuzz test commit c
for around 50 times (ie) commit and revert for 50 times