Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除github中的第一次提交_Git_Github - Fatal编程技术网

删除github中的第一次提交

删除github中的第一次提交,git,github,Git,Github,开始时,我提交了一些测试提交,包含600k+行代码。在那之后,我删除了所有的文件,像平常一样使用git 现在我在贡献者统计中看到,我添加和删除了超过650k行的代码 有没有办法删除第一个测试提交? (我只是想得到正确的统计数据) 编辑:这是我的提交历史记录: 1提交:+600k行(初始提交) 2提交:-600k行(主控现在为空) 3 Commit:+100行(仅gitignore)假设分支称为master,它有10个线性修订 git checkout master~7 # checkout t

开始时,我提交了一些测试提交,包含600k+行代码。在那之后,我删除了所有的文件,像平常一样使用git

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

有没有办法删除第一个测试提交? (我只是想得到正确的统计数据)

编辑:这是我的提交历史记录:

  • 1提交:+600k行(初始提交)
  • 2提交:-600k行(主控现在为空)

  • 3 Commit:+100行(仅gitignore)假设分支称为master,它有10个线性修订

    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
    

    你可以,但我不认为这会伤害git的精神,即跟踪历史。你可以做gitsquash@Alexangit squash不是只适用于最后n次提交吗?@YesThatIsMyName你的意思是我将测试提交更改为另一个用户,这样我的统计数据就可以了,只需要一个“testuser”就可以提交了吗?比如说30次修订,希望第四次提交作为开始:签出主人~26,--软主人~29和樱桃采摘主人~26?最后一个问题。我有一个1文件的合并。合并已与“17a9c4b”+“1e43056”合并为提交“47f92b3”。如果可以删除1e43056中的更改并使用第一个父级,那么git cherry pick master~26..master-m 1 47f92b3是否正确?我想您可以使用cherry pick的选项,以在历史中保留合并。