[Git] Move some commits to a separate branch that I have accidentally committed to master

Git进阶
本文介绍如何将错误地提交到master分支的代码回滚,并重新提交到正确的特性分支中。通过使用git命令,可以轻松地实现这一操作,保持项目分支的整洁。

Gosh no, I just added all of these commits to master. They were thought to be peer reviewed first in a dedicated branch! No worries, in this lesson we’re going to see a couple of commands that will help you move your commits into a dedicated feature branch.

Note: This only holds if you did not yet push your changes to the remote repository

 

For example, latest commits should goes to feature branch not the master branch.

 

First checkout a new branch. So that we can keep all the changes we made.

Then back to master branch

What should we do is reset the head to '9a7f06b':

git reset --hard 9a7f06b

 

转载于:https://www.cnblogs.com/Answer1215/p/10596619.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值