如何在新的git服务器中导入旧的repo文件

时间:2017-06-02 07:40:27

标签: git version-control repository

我最近在服务器出现故障后恢复。我仍然可以访问我的旧文件系统,但无法启动它。 (作为外部硬盘访问) 我从头开始重建服务器并完成此操作,我需要从旧的git服务器导入repo。

所以我的问题是:如何从Ubuntu 12.0上的git服务器导入旧的repo到Ubuntu 16.0上的新git服务器?

我需要复制哪些文件以及在哪里?

4 个答案:

答案 0 :(得分:0)

你看过 - Import an existing Git project into Bitbucket Server吗?

git clone --bare https://username@oldGitServer.com/exampleuser/old-repository.git
cd old-repository
git remote add newGitServer https://username@newGitServer.com/yourproject/repo.git
git push --all newGitServer
git push --tags newGitServer
cd ..
rm -rf old-repository

答案 1 :(得分:0)

您可以同时访问这两个文件系统,因此以下内容适合您。

Git在本地存储所有内容,因此只需将整个目录复制到您想要的任何位置即可。一定要复制隐藏文件,因为要复制的主目录是.git/,其中存储了所有提交,标记,分支等。

cp -r /path/to/old/repo /path/to/new

如果是现有目录,上述内容会将repo/复制到new/。否则,它会将repo/的内容放在(然后创建的)new/目录中。

答案 2 :(得分:0)

复制并粘贴项目文件夹。在该文件夹中,您应该看到一个包含存储库的.git文件夹。

关于'where'...只是保持旧服务器的相同路径

答案 3 :(得分:0)

您可以使用 git bundle 将旧回购导入新的git服务器并保留提交历史记录:

# In local copy of old server repo
git bundle create repo.bundle --all
# In an empty folder, copy the repo.bundle in it and run below commands,
git clone repo.bundle oldServer
cd oldServer
# checkout all branches locally
git remote add new <URL for new server>
git push new --all