David Goldfarb
David Goldfarb

Reputation: 1886

Git persistent branch with all but one commit

Normally, if I had done some work on a feature but will not be able to deploy it to master until some indefinite future time, I'd just put it in a branch and occasionally rebase that branch to the latest changes to master.

Today, I have a situation that does not quite match that common case: I made a change to master a while back, now deep in the history. I've now decided that this change is not appropriate, so I will undo it at in master. However, I do want to save this code in a branch, because it may be relevant someday.

Upvotes: 0

Views: 53

Answers (1)

David Goldfarb
David Goldfarb

Reputation: 1886

As I wrote this question, the answer became obvious. (Stack Overflow as the ultimate rubber duck debugger?)

I just need to:

  • Undo the feature in a new commit in master
  • Create the new branch
  • In the new branch, git revert the commit that undid the feature
  • In the future, rebase the branch on to master as needed

Upvotes: 1

Related Questions