Let's say in master
I have a feature disabled. I work on that feature on branch feature
, so I have a special commit $
there that just enables that feature. Now I want to merge the changes I did in feature
into master
, but keep the enabling commit out. So it's like
main: A--B--X--Y feature: A--B--$--C--D
So let's say I want to do it, by moving the $
commit on top of feature:
new feature: A--B--C--D--$
How would I go about doing that?
Interactive Rebase also allows you to reorder commits. Simply drag and drop a commit between two existing commits to reorder history.
The closest that I know how to do is to copy all of the files that were changed in the commit to somewhere else, reset the branch to the commit before the commit that you're trying to move into the staging area, move all of the copied files back into the repository, and then add them to the staging area.
What is git rebase? Rebasing is the process of moving or combining a sequence of commits to a new base commit. Rebasing is most useful and easily visualized in the context of a feature branching workflow.
git rebase -i B
, and then move $
to the end of the list that shows up in your editor. It will start out as the first line in the file that opens. You could also just delete that line entirely, which will just drop that commit out of your branch's history.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With