git 整理历史技巧

git 整理历史技巧

git reset --soft HEAD~3 && git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"



中间两个点,不是三个点

HEAD..HEAD@{1}



合并最近三次的历史


提交到远程

git push origin --force



If you want to start editing the new commit message with a concatenation of the existing commit messages (i.e. similar to what a pick/squash/squash/…/squash git rebase -i instruction list would start you with), then you need to extract those messages and pass them to git commit:



Squash my last X commits together using Git





删除 untracked files

git clean -f

连 untracked 的目录也一起删掉

git clean -fd





修改最近的一条提交记录

( 尚未提交到,远程仓库 )

修改后,最近的 commit id , 会变掉


git commit --amend

Rewriting the most recent commit message

You can change the most recent commit message using the git commit --amend command.

In Git, the text of the commit message is part of the commit. Changing the commit message will change the commit ID

–i.e., the SHA1 checksum that names the commit. Effectively, you are creating a new commit that replaces the old one.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值