一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - 編程技術 - 詳解git倉庫遷移的兩種解決方案

詳解git倉庫遷移的兩種解決方案

2020-08-01 19:14ZhangRuoxu 編程技術

這篇文章主要介紹了詳解git倉庫遷移的兩種解決方案,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

Git倉庫遷移而不丟失log的方法

要求能保留原先的commit記錄,應該如何遷移呢?

同時,本地已經clone了原倉庫,要配置成新的倉庫地址,該如何修改呢?

注意:如果使用了代碼審核工具Gerrit,那么在進行操作之前需要將Gerrit關掉,等成功恢復后再將Gerrit開戶即可

1、使用git push --mirror

先了解一些git的基本參數介紹

git clone --bare

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
GIT-CLONE(1)      Git Manual      GIT-CLONE(1)
 
NAME
  git-clone - Clone a repository into a new directory
 
SYNOPSIS
  git clone [--template=<template_directory>]
     [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
     [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
     [--depth <depth>] [--recursive] [--] <repository> [<directory>]
  --bare
   Make a bare GIT repository. That is, instead of creating <directory> and placing the administrative files
   in <directory>/.git, make the <directory> 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.<remote>.mirror is set.

1、建立新倉庫

1). 從原地址克隆一份裸版本庫,比如原本托管于 GitHub,或者是本地的私有倉庫

?
1
git clone --bare git://192.168.10.XX/git_repo/project_name.git

2). 然后到新的 Git 服務器上創建一個新項目,比如 GitCafe,亦或是本地的私有倉庫,如192.168.20.XX

?
1
2
3
4
su - git
cd /path/to/path/
mkdir new_project_name.git
git init --bare new_project_name.git

3). 以鏡像推送的方式上傳代碼到 GitCafe 服務器上。

請確保已經添加了公鑰到新的機器上

?
1
2
cd project_name.git
git push --mirror [email protected]/path/to/path/new_project_name.git

4). 刪除本地代碼

?
1
2
cd ..
rm -rf project_name.git

5). 到新服務器上找到 Clone 地址,直接Clone到本地就可以了。

?
1
git clone [email protected]/path/to/path/new_project_name.git

這種方式可以保留原版本庫中的所有內容。

2、切換remote_url

先查看remote的名字

?
1
git branch -r

假設你的remote是origin,用git remote set_url 更換地址

?
1
git remote set-url origin remote_git_address

remote_git_address更換成你的新的倉庫地址。

第二種切換remote_url的方法更直接,直接更改.git/conf配置文件里的ip地址就行。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

原文鏈接:https://www.cnblogs.com/ZhangRuoXu/p/6706530.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 久久国产精品高清一区二区三区 | 国产草草视频 | 午夜理论片日本中文在线 | 久久国产视频网 | 五月天中文在线 | 精品视频一区二区三区免费 | 亚洲爱v | 嫩草影院永久在线一二三四 | 男人操美女视频 | 手机在线观看国产精选免费 | 色一情一乱一伦 | 2022最新国产在线不卡a | 免费在线公开视频 | 欧美成人影院免费观 | 精品国产成人a区在线观看 精品高潮呻吟99AV无码视频 | 超级乱淫伦短篇在车上 | 涩色网站 | 二次元美女扒开内裤露尿口 | 9420高清完整版在线观看国语 | 四虎影院免费在线 | bbbbbbaaaaaa毛片| 糖心vlog麻豆精东影业传媒 | 欧美办公室silkstocking | 99久久久久国产精品免费 | 国产人妖xxxxx免费看 | 亚洲色图欧美偷拍 | 国产九九在线观看播放 | 古装床戏做爰无遮挡三级 | 俄罗斯三级在线观看级 | 亚洲H成年动漫在线观看不卡 | 魔镜号中文字幕 | 婚前试爱全集免费观看 | 男人扒开| 海角社区在线视频 | 日本在线观看免费观看完整版 | 亚洲国产免费 | 99久久成人 | 色哟哟观看 | 美女被视频网站 | 欧美视频在线播放观看免费福利资源 | 99久久999久久久综合精品涩 |