删除github中的第一次提交 [英] Delete first commits in github

查看:94
本文介绍了删除github中的第一次提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一开始,我用600k +行代码提交了一些测试提交.之后,我删除了所有文件,并像往常一样使用了git.

At the beginning I committed a few test commits with 600k+ rows of Code. After that I deleted all files and just used git like normal.

现在,我在贡献者统计中看到我添加和删除了650k +行代码.

Now I see in the contributors statistic that I added and deleted over 650k+ rows of Code.

是否可以删除第一个测试提交? (我只想得到正确的统计信息)

Is there a way to delete the first test commits? (I just want to get the statistic right)

这是我的提交历史记录:

that's my commit history:

  • 1次提交:+ 60万行(初始提交)
  • 2次提交:-600k行(主机现在为空)
  • 3次提交:+100行(只是gitignore)<-我希望将此作为初始提交
  • 4次提交:+3万行(我的正常工作) ...
  • 1 Commit: +600k rows (Initial commit)
  • 2 Commit: -600k rows (master is now empty)
  • 3 Commit: +100 rows (just gitignore) <-- I would like to have this as initial commit
  • 4 Commit: +30k rows (my normal work) ...

推荐答案

假设该分支称为master,并且它具有10个线性修订版本.

Suppose the branch is called master and it has 10 linear revisions.

git checkout master~7 # checkout the 3rd revision from history
git reset --soft master~9 # set branch pointer at first revision, all diffs between master~7 and master~9 are on index
git commit --amend --no-edit # now first revision has the content (working tree) of master~7, so first two revisions from master are gone
git cherry-pick master~7..master # replay history
# if you like the result
git branch -f master # set master on new branch
git checkout master

这篇关于删除github中的第一次提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆