0%

如何删除Github上的Commit历史记录?

来源:Lestat.Z. - 如何删除Github上的Commit历史记录?

前言

之前在做测试的时候提交了很多无用的记录,现在准备将这些无用的垃圾commit记录删除。

解决方法

具体步骤如下。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Clone your git repo
git clone https://github.com/lestatzhang/lestatzhang.github.io.git
# Entre your local repo
cd lestatzhang.github.io
#Checkout
git checkout --orphan latest_branch
# Add all the files
git add -A
# Commit the changes
git commit -am "Reinitialize"
# Delete the branch
git branch -D master
# Rename the current branch to master
git branch -m master
# Finally, force update your repository
git push -f origin master
Publishing this article is for the purpose of conveying more information, and does not mean agreeing with its views or confirming its description, nor does it mean that we are responsible for its authenticity. Should you have any questions or doubts about the content of the post, please don't hesitate to contact us. We will respond to you and deal with it as quickly as possible.
推进创文常态化 共建文明襄阳城 · 🄽🄾5️⃣9️⃣7️⃣2️⃣ · 做文明襄阳人 建文明襄阳城 凝聚文明正能量 筑梦千年古襄阳 · 🄽🄾5️⃣9️⃣7️⃣2️⃣ · 创建全国文明城市 加快建设汉江流域中心城市 · 🄽🄾5️⃣9️⃣7️⃣2️⃣ · 讲文明 树新风 · 🄽🄾5️⃣9️⃣7️⃣2️⃣ · 用微笑融化陌生 用文明美化襄阳 · 🄽🄾5️⃣9️⃣7️⃣2️⃣ · 争当文明使者 播撒文明新风