简体   繁体   中英

How to remove old commits and contributors from github repository?

I and my friends started a project on Github and one of them made the repository. But they were just playing around and making unnecessary commits on there. So I decided to clone this on my own GitHub and work on it on my own. Now halfway through with around 21 commits, I realized that in the commit history it is showing their useless joke commits and also displaying them as contributors on my repo. Is there any way I can delete those old commits. And if possible remove them as contributors? Thanks!

In order to delete old commits you need to recreate that entire branch, it is not possible to delete some commits rather than only the middle 21 or something like that. So you either delete all commits or no commits.

As to do so run the following commands:

git checkout --orphan latest_branch
git add -A
git commit -am "commit message"
git branch -D master
git branch -m master
git push -f origin master

And the end your old commit history will be deleted.

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