rrauenza
rrauenza

Reputation: 6993

Base a new change on a reverted commit?

I submitted a change (ORIG) to git and then reverted (REVERT) it. I could revert ORIG commit contents but with additional fixes -- i.e., a brand new consolidated commit that is correct this time.

I suppose I could use git to print out the files from ORIG ... but this is error prone, especially with lots of files.

Is there a good reliable foolproof workflow for this?

Upvotes: 0

Views: 37

Answers (1)

LightBender
LightBender

Reputation: 4253

Yes, it's quite straight forward:

git revert -n <revert commit>

The -n tells it not to create a commit, but instead just stage the changes and wait for input. Make your changes, stage them and commit normally.

This will work even if there were multiple commits that were reverted in your revert commit.

An alternate method, if your original changes were in just one commit:

git cherry-pick -n <original commit>

Upvotes: 1

Related Questions