简体   繁体   English

Git将仓库迁移到另一台服务器

[英]Git migrate repo to another server

I realize that this question has been asked several times. 我意识到这个问题已经被问过几次了。 I went through almost all of those before asking it here. 在这里问之前,我经历了几乎所有这些问题。

I have a git repo on server A and want it to push on remote server B. 我在服务器A上有一个git repo,并希望它在远程服务器B上推送。

Steps i followed: 我遵循的步骤:

On server B: 在服务器B上:

    mkdir repo
    cd repo
    git init --bare
    ls
    branches  config  description  HEAD  hooks  info  objects  refs

On server A where my local repo is present. 在存在我的本地存储库的服务器A上。

cd localrepo
git remote add new-origin root@B:/root/repo
git push new-origin master
Counting objects: 12, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (12/12), 976 bytes | 0 bytes/s, done.
Total 12 (delta 1), reused 0 (delta 0)
To root@172.16.189.221:/root/four
 * [new branch]      master -> master

Now when i check on server B. Cannot find the updated files. 现在,当我检查服务器B时。找不到更新的文件。 each time i update on localrepo on A and do a push to B. it updates the contents under objects folder in B but am unable to see the files. 每次我在A上的localrepo上更新并推送到B时,它都会更新B中object文件夹下的内容,但看不到文件。

Could anyone point me in the right direction :) 谁能指出我正确的方向:)

A bare repository does not contain a working tree. 裸存储库不包含工作树。 (That's why it is called bare.) Therefore you cannot see the files directly. (这就是为什么它被称为裸露的原因。)因此,您无法直接看到文件。 (You see only those files, which live in .git on a non-bare repository.) (您只能看到这些文件,这些文件位于非裸存储库中的.git 。)

Use git ls-files to see which files are present. 使用git ls-files查看存在的文件。 Use git log to see which commits are present. 使用git log查看存在哪些提交。

To actually "move" the repository to another server I would simply use 实际将存储库“移动”到另一台服务器,我只会使用

git clone --mirror $original_url

on the new server. 在新服务器上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM