git - Git:如何在没有壁球的情况下修复合并
问题描述
我在没有压缩的情况下合并到 master 现在它显示了对我的分支所做的每一个提交myTestBranch
。
有什么办法可以修复它以显示单个提交?
解决方案
您可以尝试,rebase
但如果存储库被多个开发人员使用,请尝试协调这一点,因为它会更改/更改存储库的历史记录,例如:
$ git rebase -i <commit>
<commit>
您想返回/还原的提交的哈希在哪里,在这里,您可以使用它来获取最后一次提交的列表:git log --pretty=oneline --abbrev-commit
当使用选项-i
(交互式)变基时,它将打开您的编辑器并显示如下内容:
pick 447dae2 my changes for foo bar
pick 452b764 1
pick 9aaf8b3 2
pick 15a6af0 3
pick f31a830 4
pick dd34521 5
# Rebase 5302aa0..dd34521 onto 5302aa0 (6 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
所以在这里你可以通过为提交添加前缀来“修复”或“挤压”,例如:
pick 447dae2 my changes for foo bar
f 452b764 1
f 9aaf8b3 2
f 15a6af0 3
f f31a830 4
f dd34521 5
# Rebase 5302aa0..dd34521 onto 5302aa0 (6 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
然后你将不得不推动力量:
$ git push -f
你的梨,可能需要做:
$ git pull --rebase
检查此答案以获取更多详细信息:https ://stackoverflow.com/a/42862404/1135424
推荐阅读
- python - 在 sqlalchemy 对象中应用操作
- java - Java以Python方式获取子列表
- java - 通过 Selenium 和 Java 使用 CssSelector 识别新添加的元素
- php - 如何将我的原生 PHP 代码转换为 Codeigniter 代码
- excel - 基于查找提取其他列值
- python - 根据数据框中的条件删除组 - pandas groupby
- kentico - 如何修复“未指定 DocumentName 值。” 即使已经提供了 DocumentName 属性
- php - 在公共包中创建实体的最佳方式
- ibm-mobilefirst - IBM MFP8 Oracle 二进制问题
- javascript - Angular 7 Guard 重定向仅适用于双击