Git倉(cāng)庫(kù)遷移而不丟失log的方法
要求能保留原先的commit記錄,應(yīng)該如何遷移呢?
同時(shí),本地已經(jīng)clone了原倉(cāng)庫(kù),要配置成新的倉(cāng)庫(kù)地址,該如何修改呢?
注意:如果使用了代碼審核工具Gerrit,那么在進(jìn)行操作之前需要將Gerrit關(guān)掉,等成功恢復(fù)后再將Gerrit開戶即可
1、使用git push --mirror
先了解一些git的基本參數(shù)介紹
git clone --bare
GIT-CLONE(1) Git Manual GIT-CLONE(1) NAME git-clone - Clone a repository into a new directory SYNOPSIS git clone [--template=] [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror] [-o ] [-b ] [-u ] [--reference ] [--depth ] [--recursive] [--] [ ] --bare Make a bare GIT repository. That is, instead of creating and placing the administrative files in /.git, make the itself the $GIT_DIR. This obviously implies the -n because there is nowhere to check out the working tree. Also the branch heads at the remote are copied directly to corresponding local branch heads, without mapping them to refs/remotes/origin/. When this option is used, neither remote-tracking branches nor the related configuration variables are created. git push --mirror --mirror Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote. .mirror is set.
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。