move not ready commits to another branch
I am working on a feature that I think it should be ready soon,
so I am developing that feature on working dev branch.
But later found that it's not so easy to make it work right,
need to move those changes (commits) to another branch.
The problem is that the dev branch has diverged already,
so I can't just reset --hard to discard those changes.
What I would need now is move my not pushed but committed
changes off the dev branch to keep it working,
while preserve my commits. That's one of the reasons
to use git rebase, I suppose.
The commit history is roughly as following:
Good -> Good -> NG -> NG -> Good -> Good
NG is Not Good, and it's not pushed yet.
(thus I can use rebase, or forget about it)
So the steps are as following:
> git rebase github/dev
this would rewrite the history to:
Good -> Good -> Good -> Good -> NG -> NG
Then you can merge this into topic branch now:
> git checkout dev-topic
> git merge dev
or if there haven't one topic branch already:
> git checkout -b dev-topic
And now we can discard the commits in dev branch:
> git reset --hard github/dev
So far so good.
0 retries:
Post a Comment
Note: Only a member of this blog may post a comment.