git - 如何压缩 git 历史中的一系列提交?
问题描述
我想将多个提交压缩在一起,但它们都不是当前的负责人。这是它的样子:
commit 7e3641f857b4fb15362c43354de5f14846a461b1 (HEAD -> superset-custom-exporter, origin/superset-custom-exporter)
Author: Aviral Srivastava
Date: Wed Nov 4 11:41:32 2020 -0500
adds env vars pertaining to postgresdb deployment with odh
commit bae9321ea4f78973adcc50c92a10eaebd703c7eb
Author:
Date: Wed Oct 21 08:55:37 2020 -0300
Fix the security role for new logged in users
commit 2974314ca485c526ed2272f6c8bad443653765ab
Author:
Date: Thu Oct 15 13:39:08 2020 -0400
Revert "wip"
This reverts commit 0a93c50120b49a6ad850ee0cf8b1ab0523d50f97.
commit second_commit
Author:
Date: Thu Oct 15 11:50:24 2020 -0400
wip
commit some_commit
Author:
Date: Thu Oct 15 10:30:47 2020 -0400
Upgrade to superset version 0.37.2
commit some_commit
Author:
Date: Thu Oct 22 12:40:49 2020 -0400
wip
commit some_commit
Author:
Date: Thu Oct 22 12:19:47 2020 -0400
adds slices monitoring
commit first_commit
Author:
Date: Thu Oct 15 16:07:03 2020 -0400
我想将提交从哈希second_commit
压缩first_commit
到一个单独的提交。我了解如何从当前具有过去范围的当前执行此操作,但是当两个提交都过去时,我不知道如何执行此操作。
解决方案
实际上,要压缩您的项目,您不仅应该移动头部,还应该将 master 移动到相同的位置。
要做到这一点 1.你应该在软中重置 >>>>>> git reset --soft [第二次提交的哈希值] 2.将你修改的提交作为下一次提交 >>git commit -am "The last commit"
现在你已经被压扁了。实际上,使用“git log --oneline”而不是“git log”命令。它会缩短您的文本。
推荐阅读
- android - 重复类 com.google.android.gms.location.places.zza
- javascript - 吉森没有假设正确的语法
- python - Plotly:如何重写标准仪表板应用程序以在 JupyterLab 中启动它?
- android - 暂停执行,直到通过 LiveData 设置对象值
- python - 在将 LatLong 转换为 UTM、将偏移量添加到 UTM 以及将偏移量 UTM 转换回 LatLong 时如何处理可能的区域变化?
- python - 如何将值从一个列表移动到另一个列表,同时从第一个列表中删除它们
- c# - 为什么 UserControl 上的表单没有 PostBack?
- r - 以特定方式转换数据框列名称
- android - 哪些版本的安卓可以在关闭 GPS 的情况下请求位置?
- javascript - 这个 npm err 的根源是什么以及如何修复它?