简体   繁体   English

如何删除我的回购记录中的第一次提交?

[英]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 --rootnode_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.

相关问题 如何使用git rebase使我的提交历史记录有效? - How can I make my commit history work with git rebase? 如何回滚 Git 存储库以首先提交并删除所有历史记录 - How to roll back Git repo to first commit and delete all history 如何从 github 上的 forked repos 中找到最新的提交? - How can I find the latest commit from forked repos on github? 如何在Git中删除已经推送到远程分支并出现在我的同事本地存储库中的提交? - How to delete a commit in Git that is already pushed to a remote branch and present in my coworkers local repos? 我如何从git历史记录中删除提交,好像根本没有提交一样? - How do I delete a commit from git history as if it was not at all there? 如何搜索我的整个git repo的提交历史记录以进行字符串更改? - How can I search my ENTIRE git repo's commit history for a string change? 如何找到提交历史记录中存在特定代码行的文件? - How can I find the file that a particular line of code existed within in my commit history? 为什么我的提交历史记录看起来像这样,我该如何解决呢? - Why does my commit history look like this and how can I go about fixing it? 如何在 git 存储库中缩进我的代码并在没有历史记录的情况下提交和合并? - How can I indent my code in a git repo and commit and merge without history? 如何删除TortoiseGit中的URL历史记录? - How can I delete the URL history in TortoiseGit?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM