Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
git将多个提交压缩为多个提交_Git_Version Control_Commit - Fatal编程技术网

git将多个提交压缩为多个提交

git将多个提交压缩为多个提交,git,version-control,commit,Git,Version Control,Commit,有鉴于此: 假设我有这个重基: pick 16b5fcc msg1 pick c964dea msg3 pick 06cf8ee msg1 pick 396b4a3 msg2 pick 9be7fdb msg3 pick 7dba9cb msg2 假设我想将具有相同消息的所有Comitt合并为一个…(即所有msg1提交为一个msg1提交,所有msg2提交为一个msg2提交,等等) 我该怎么把这些压扁呢 git rebase允许您重新排序和挤压提交。这样的事情应该行得通: pick 16b5f

有鉴于此:

假设我有这个重基:

pick 16b5fcc msg1
pick c964dea msg3
pick 06cf8ee msg1
pick 396b4a3 msg2
pick 9be7fdb msg3
pick 7dba9cb msg2
假设我想将具有相同消息的所有Comitt合并为一个…(即所有msg1提交为一个msg1提交,所有msg2提交为一个msg2提交,等等)


我该怎么把这些压扁呢

git rebase允许您重新排序和挤压提交。这样的事情应该行得通:

pick 16b5fcc msg1
squash 06cf8ee msg1
pick 396b4a3 msg2
squash 7dba9cb msg2
pick 9be7fdb msg3
squash c964dea msg3

如果您有很多提交,我建议您编写一个脚本,如上所述对它们进行分组。

如果您不想一路上编辑每个提交消息,也可以使用
fixup
而不是
squash
。重新排序提交!这让我很紧张。我想知道在这种
重设基础
之后,文件的实际内容会是什么样子。你真的成功地使用了这个吗?