Weil Jimmer's BlogWeil Jimmer's Blog


Month:January 2025

Found 1 records. At Page 1 / 1.

[筆記] Git 儲存庫從 SHA256 降級為 SHA1 經驗

No Comments
-
發布於 2025-01-23 00:37:48

前言

昨晚心血來潮,用了 Gitea 建了一個儲存庫,那時候手賤選了 SHA256,想說要用最新的,結果當我寫完專案,想要備份到 Github 上,才發現推送不上去,跳出錯誤。


fatal: the receiving end does not support this repository's hash algorithm
fatal: the remote end hung up unexpectedly

看到關鍵詞 hash algorithm 就知道是選了 SHA256 的黑鍋。

如果遇到,最快的方式是直接建一個新專案,然後 add 全部代碼,然後 commit,這是最快的解法。

當時,就是想要保留歷史紀錄,結果找老半天,沒找到怎麼保留歷史紀錄轉換成 SHA-1 的方法,真的是爬很多資料,試了一堆方法。

下面分享我試成功的命令。

將 SHA256 專案轉成 SHA1 的格式

在 SHA-256 repo 中,export 紀錄。

cd original-repo
git fast-export --all --use-done-feature --reencode=yes > ../export.dat

建立 SHA1 的新專案

cd ../new-repo
rm -rf * .git  # 清空目錄
git init --object-format=sha1

匯入所有歷史紀錄

git fast-import --quiet < ../export.dat

重建 & 清理

git checkout main
git gc --aggressive

重新簽章(非必要)(Rebase)


git rebase --root -i --exec 'git commit --amend --no-edit -S'
# -i 代表互動模式
# --root 從第一個提交開始
# -S 代表用目前的 GPG key 簽署

By Weil Jimmer


This entry was posted in General, Experience, Git By Weil Jimmer.

 1 /1 頁)

Visitor Count

pop
nonenonenone

Note

台灣假新聞橫行,沒一家霉體能信的,網軍側翼到處洗風向,堪憂。

政府根本不怕你拿法律當武器,只怕你放下法律拿起武器

不要和愚蠢的人發生爭執。

支持網路中立性.
Support Net Neutrality.

飽暖思淫欲,
饑寒起盜心。

朱門酒肉臭,
路有凍死骨。

支持臺灣實施
無條件基本收入

歡迎前來本站。

Words Quiz


Search

Music

Blogging Journey

4529days

since our first blog post.

Quotes

The strong do what they can and the weak suffer what they must.

Privacy is your right and ability to be yourself and express yourself without the fear that someone is looking over your shoulder and that you might be punished for being yourself, whatever that may be.

It is quality rather than quantity that matters.

I WANT Internet Freedom.

Reality made most of people lost their childishness.

Justice,Freedom,Knowledge.

Without music life would be a mistake.

Support/Donate

This site also need a little money to maintain operations, not entirely without any cost in the Internet. Your donations will be the best support and power of the site.
MethodBitcoin Address
bitcoin1gtuwCjjVVrNUHPGvW6nsuWGxSwygUv4x
buymeacoffee
Register in linode via invitation link and stay active for three months.Linode

Support The Zeitgeist Movement

The Zeitgeist Movement

The Lie We Live

The Lie We Live

The Questions We Never Ask

The Questions We Never Ask

Man

Man

THE EMPLOYMENT

Man

In The Fall

In The Fall

Facebook is EATING the Internet

Facebook

Categories

Android (7)

Announcement (4)

Arduino (2)

Bash (2)

C (3)

C# (5)

C++ (1)

Experience (53)

Flash (2)

Free (13)

Functions (36)

Games (13)

General (62)

Git (3)

HTML (7)

Java (13)

JS (7)

Mood (24)

NAS (2)

Note (33)

Office (1)

OpenWrt (6)

PHP (9)

Privacy (4)

Product (12)

Python (4)

Software (11)

The Internet (26)

Tools (16)

VB.NET (8)

WebHosting (7)

Wi-Fi (5)

XML (4)