Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
456 views
in Technique[技术] by (71.8m points)

branch - Git: move a commit "on top"

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?

question from:https://stackoverflow.com/questions/14507510/git-move-a-commit-on-top

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...