简体   繁体   English

如何将所有先前的提交合并为一个提交?

[英]How to merge all previous commits into a single commit?

Context: Started project on GitHub and have been experimenting with git commands. 上下文:在GitHub上启动项目并且一直在试验git命令。 The history of the project is untidy. 该项目的历史是凌乱的。

Question: How can I remove all history and replace all commit messages with something along the lines of "Uploaded initial version of project source"? 问题:如何删除所有历史记录并将所有提交消息替换为“已上载项目源的初始版本”?

此选项将允许您保留项目的所有配置文件
git reset --soft <sha_of_initial_commit>
git commit -a --amend -m "initial commit"

删除.git目录。

git init
git add .
git commit -m "Initial commit"
git push origin master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM