Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
699 views
in Technique[技术] by (71.8m points)

git - Remove commit for good

I know there are thousands of threads for this question.

But I found out something really weird.

If you create a project on GitHub, do some commits.
Let's say commit 1, 2, 3, 4, 5.
Later, you realize you want to change something into commit 3.

As you were working in your own branch, no problem to rewrite history.

So let's do this: (based on this stackoverflow answer)

git rebase --interactive 'bbc643cd^'

// Modify 'pick' to 'edit' into interactive prompt and :
git commit --all --amend --no-edit
git rebase --continue
git push -f

Great! The mistake is corrected. The history has been rewritten, so the commit bbc643cd is now lkqjfhchc.
You can check the source on your GitHub and everything will have been updated.

But someone can still find it on GitHub!

Access the URL: https://github.com/your-nickname/your-project/commit/bbc643cd... (full commit hash) and you will find it!

How could we remove this commit for good?

Thanks for any help!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I contacted Github staff from here : https://github.com/contact

Here's the answer (I couldn't do anything about it, no prune, no gc, etc)

Hey Maxime,

The commit was available because commits are not automatically deleted when they're removed from the history of a branch -- they're deleted when they're garbage collected. I just ran garbage collection for that repository manually and the commit should now return a 404.

How often does the garbage collector run on your end?

GitHub doesn't have a scheduled garbage collection process. We don't clear repository caches automatically (we're in the version control business, so we don't delete data unless we absolutely have to ??) so usually, the only reason we would do that is if we had someone writing in to us asking for us to clear them as part of the sensitive data removal process.

It's also possible we might clear the cache for technical reasons if the content or structure of the repo was causing us difficulties to host it, but that would usually only happen if the repo was exceptionally large or had a wildly structured folder layout.

Please let me know if you have any questions about this or anything else.

Hope this helps.

Cheers, XXXXX

So you just have to wait or contact staff to force garbage collector in case you have the same problem !


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...