[英]How can I delete the first commit on my repos history?
I've created a new repository in GitHub, but unfortunately I sent the first commit with node_modules In the second one I removed the node_modules and sent the .gitignore file that avoids to commit all the node_modules since that second commit. 我在GitHub上创建了一个新的存储库,但不幸的是,我使用node_modules发送了第一次提交。在第二个中,我删除了node_modules并发送了.gitignore文件,该文件避免了自第二次提交以来提交所有的node_modules。
After several more commits in the progress, I've found out that the repository size was big because that initial commit that had all the node_modules. 在进行几次提交之后,我发现存储库的大小很大,因为最初的提交包含所有的node_modules。
So, my question is: how can I delete that first commit from the log history to reduce the repository size? 因此,我的问题是:如何从日志历史记录中删除该第一次提交以减小存储库的大小?
Note: I don't care about the first commit history progress because I have much more progress in the subsequents commits 注意:我不在乎第一次提交历史记录的进度,因为在后续提交中我有更多的进度
您应该使用git rebase -i --root
并node_modules
提交,并在第一次提交时删除node_modules
文件夹。
Git uses a tree organization that is only allowed to be added new nodes (commits). Git使用仅允许添加新节点(提交)的树组织。 If you really want to delete a wrongly pushed commit you must update your repository locally and than force push to the according remote.
如果您确实要删除错误地推送的提交,则必须在本地更新存储库,然后强行推送到相应的远程服务器。 I found an issue talking about it.
我发现有一个问题在谈论。
How to undo the initial commit on a remote repository in git? 如何在git中撤消对远程存储库的初始提交?
使用git revert <commit_id_to_be_reverted>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.