What is best practice for 'git reset'?

I am maintainer of a CPAN distribution whose most recent official 
release is version 2.12.

Since 2.12 was published, we have made the following development releases:

2.12_001
2.12_002
2.12_003
2.12_004

In the git repository, we have tags for:

2.12_002
2.12_003
2.12_004

(Somehow 2.12_001 was overlooked or has not yet been set.)

I now realize that much of the code (mostly tests, but some source) 
added in 2.12_003 and 2.12_004 is conceptually flawed.  For other 
developers and myself to treat 2.12_004 as the starting point for future 
development would not be fruitful.

What I would like to do is to go back to 2.12_002 and start development 
anew from there -- but without pretending that 2.12_003 and 2.12_004 
were never released.  I would like 2.12_005 to be equivalent to 2.12_002 
but with only very safe, minor touchups.

Would the following be the recommend sequence of git commands?

$ git checkout master
$ git checkout -b start-anew
$ git reset --soft 2.12_002
$ git commit -m "Rewind to tag 2.12_002"
# hack, hack, hack
$ git add ...
$ git commit -m "Slight touchups to what was 2.12_002"
$ git checkout master
$ git merge start-anew
$ git tag "2.12_005"

Thank you very much.
Jim Keenan
0
jkeenan
4/19/2017 9:30:58 PM
perl.module-authors 1553 articles. 0 followers. Follow

1 Replies
50 Views

Similar Articles

[PageSpeed] 43

On Wednesday, 19 April 2017 17:30:58 CEST James E Keenan wrote:
> Would the following be the recommend sequence of git commands?
> 
> $ git checkout master
> $ git checkout -b start-anew
> $ git reset --soft 2.12_002

git reset --soft does not change the working tree. So the change between 
2.12_002 and 2.12_004 would not be reverted.

I'd suggest instead to do a git revert like:
$ git revert -n 2.12_002..master

This command will also revert 2.12_002. If this is not desirable, you will 
have to find the first commit you want to revert and do:

$ git revert -n <first-bad-commit>..master

Then you can go on with what you suggest below.

> $ git commit -m "Rewind to tag 2.12_002"
> # hack, hack, hack
> $ git add ...
> $ git commit -m "Slight touchups to what was 2.12_002"
> $ git checkout master
> $ git merge start-anew
> $ git tag "2.12_005"

HTH

-- 
 https://github.com/dod38fr/   -o- http://search.cpan.org/~ddumont/
http://ddumont.wordpress.com/  -o-   irc: dod at irc.debian.org
0
domi
4/20/2017 1:34:52 PM
Reply: