[Git] Undo my last commit and split it into two separate ones

本文介绍如何在未推送更改到远程仓库前撤销已提交的更改,并将其拆分为单独的提交。通过使用git reset命令回退到上一个提交,然后可以进一步处理文件以创建新的提交。

When you accidentally committed some changes to your branch you have various possibilities to “undo” that operation and add some more changes. One is to use git amend to change the commit message or add new files. But what we want to take out all of the committed changes again and maybe even split them into separate commits. Let’s see how we can achieve that. Note: This only holds if you did not yet push your changes to the remote repository.

 

In this case, what we can do is first do the reset:

git reset HEAD~

 

Then spreate files into diifferent commit messages.

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值