简体   繁体   中英

Delete first commits in github

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.

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)

Edit: that's my commit history:

  • 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) ...

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

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