清除GIT中的所有提交?
我在我们的服务器上创建了一个新的 git 存储库,然后提交了所有文件。提交这些文件后,我创建了一个新的 .gitignore 文件并提交了它。
我以错误的顺序进行了两次提交,因为原始提交添加了大约 30k 个文件,而 .gitignore 文件没有任何影响。如果我可以清除这两个提交,然后首先提交 .gitignore 文件,希望它会大大减少文件量并使存储库更小。
这可能吗?我从未将存储库推送到 BeanstalkApp(我们托管的 git 帐户),所以希望这是可能的。
谢谢,
丹尼
I created a new git repo on our server and then committed all files. Once those files were committed I then created a new .gitignore file and committed it.
I did the two commits in the wrong order because the original commit added around 30k files and the .gitignore file isn't having any affect. If I could clear both commits and then commit the .gitignore file first hopefully it will dramatically reduce the volume of files and make the repo smaller.
Is this possible? I have never pushed the repo to BeanstalkApp (our hosted git account) so hopefully it is possible.
Thanks,
Danny
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您确实刚刚创建了存储库,那么我建议您重新创建它——可以从 git 的修订历史记录中完全删除文件,但根据我的经验,速度相当慢。
If you really just created the repo then I'd recommend you just recreate it -- it's possible to remove files entirely from the revision history in git but in my experience it's quite slow.
您可以应用新的提交来删除不需要的文件。从那时起,它们将根据 .gitignore 文件被忽略。
或者,您可以尝试 git rebase -i HEAD~2 并简单地删除初始提交。
You can apply a new commit which removes the unwanted files. From that point on, they will be ignored as per the .gitignore file.
Or, you can try
git rebase -i HEAD~2
and simply delete the initial commit.