简体   繁体   中英

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.

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.

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). 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 revert <commit_id_to_be_reverted>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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