git重写历史记录

1 修改上一次历史提交,替换掉上次的提交
git commit --amend

2 git rebase 将不同分支路径合并到同一分支路径上
eg:将master分支上的 conflic rebase合并到 head分支上
* ada88de(HEAD, test_rebase)Initial commit on test_rebase
| *2a4a11f (master) coflict rebase
| /
|/
* ac75384 This is a amend commit


$ git rebase master

1 如果发生冲突 可以执行git rebase --abort撤销
2 解决冲突 vim编辑冲突文件 ,
3 git rebase --continue,
4 git add 冲突文件,
5 git rebase --continue

结果:
* ada88de(HEAD, test_rebase)Initial commit on test_rebase
*2a4a11f (master) coflict rebase
|
|
* ac75384 This is a amend commit

 

如果像回到git rebase操作执行之前

git reflog查看所有head记录

使用git reset -- hard HEAD@{N} (N代表数字 )回到操作前的某一次提交

git reset --soft commit 只将版本库中的head指向commit
git reset --mixed commit 将版本库中的 head指向commit ,使用commit分支文件替换暂存去

git reset --hard commit 版本库指向commit ,替换了暂存去和工作区

转载于:https://www.cnblogs.com/or2-/p/4943996.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值