git命令每日总汇-合并多个commit

比方我们要合并最近9次的commit为一个commit
1、 查看提交历史(最近10次的)

git log -10

2、. 回到前面第十个commit,且将后面九个commit提交的内容状态改为未提交

git reset commitID(从最近往前数第十个commit的ID, 也就是上面的命令查询出来的最下面的那个commitID)

3、 提交修改的内容

git add .
git commit -m "描述信息"

4、提交到远程分支

git push

To http://xxxxxxxxxxxxxxxx
! [rejected] 分支名称-> 分支名称 (non-fast-forwards)
error: failed to push some refs to 'http://xxxxxxxxxxxxxxxxxxxxxxxxxxxx
hint: Updates were rejected because the tip of your current branch is behin
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.

5、执行上面的命令后会报如上的错误,由于本地没有远程的前9个commit节点

6、如果该分支上的代码仅你一个人在更新,可以强制执行本地代码覆盖远程代码操作(远程的前9个commit将删除,本地的合并后的commit将推到远程仓库):

git push -f origin 远程分支名称
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值