将最新提交移至其他现有分支 [英] Move most recent commit to a different existing branch

查看:73
本文介绍了将最新提交移至其他现有分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚对功能分支进行了一些更改,但是我意识到我在错误的分支上。

I just committed some changes to a feature branch, but I realize I was on the wrong branch.

我如何接受我所做的最后一次提交并移动到另一个已经存在的分支?我还没有推送任何内容。

How do I take the last commit I made, and move it to a different, already existing, branch? I haven't pushed anything yet.

我已经看到了一些类似的问题,但是它们都涉及创建新分支,而他们所进行的所有硬性重置是

I've seen some similar questions but they all involve creating a new branch, and all the hard head resetting they're doing is a mite scary.

推荐答案

git checkout whereishouldhaveputit
git cherry-pick whereididputit
git checkout -B whereididputit whereididputit~

这篇关于将最新提交移至其他现有分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆