如何将所有提交历史压缩为一个提交?

时间:2014-06-13 16:42:23

标签: git github

所以我使用了以下内容:

git checkout --orphan newBranch
git add -A  # Add all files and commit them
git commit
git branch -D master  # Deletes the master branch
git branch -m master  # Rename the current branch to master

对于Gitrepo提交历史来说效果很好,但是,当我使用gitk时 - 我仍然会看到所有先前的提交。是否也可以将所有这些提交合并为一个?

谢谢!

1 个答案:

答案 0 :(得分:1)

使用git rebase -i --root。 然后更改除pick之前的所有行的前缀到squash。 所有提交都将在一次提交中合并。

当然,当您推动更改时,您需要强制推送,否则它不会推动您的更改。

相关问题