Git: move a commit “on top”

丶灬走出姿态 提交于 2019-11-28 19:16:23

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 want to keep you commits in the same order on feature you should make a new branch and perform the following. Otherwise just do this on feature

git rebase -i <sha for commit B>

Move commit $ to the bottom of the list

git checkout master
git rebase feature <or the other branch name>

It wasn't clear to me on the question but if you didn't want $ at all, rather than moving it delete it after git rebase -i Though you will want to do this on a new branch so that you don't lose it. As you are changing history.

This also assumes that the branch feature hasn't been pushed to a remote as rewriting history is bad.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!