简体   繁体   English

如何将 github 本地存储库复制到另一台计算机?

[英]How to copy a github local repo to another computer?

I have a new PC and need to copy my local github for windows repos to the new computer.我有一台新电脑,需要将我的本地 github 用于 windows 存储库复制到新电脑。 All repositories are on github, but I do not want to download them all again to the new computer.所有存储库都在 github 上,但我不想再次将它们全部下载到新计算机上。

Is there any way to add this local files to the new computer using github for windows (or shell) and then just push/pull/sync the changes with the github.com? Is there any way to add this local files to the new computer using github for windows (or shell) and then just push/pull/sync the changes with the github.com?

Thank you all Regards谢谢大家的问候

Paulo保罗

If I understand correctly you are trying to avoid pushing unfinished local changes to the repo. 如果我理解正确,你试图避免将未完成的本地更改推送到回购。 No problem. 没问题。

Git repos are self-contained. Git repos是独立的。 Just copy the repo directories from one machine to the other. 只需将repo目录从一台机器复制到另一台机器。 Nothing fancy required. 什么都不需要。

You could clone your repos from another machine through local network with git+ssh 您可以使用git+ssh通过本地网络从另一台计算机克隆您的存储库

git clone git+ssh://user@192.168.1.5/~/repos

or just copy files and setup git on you new PC manually. 或者只是手动复制文件并在新PC上设置git。

I was in a similar situation but with a Mac (not PC). 我处于类似的情况,但使用Mac(不是PC)。 With Mac, I backed up my old computer using Time machine and restored the new computer with that backup. 使用Mac,我使用Time machine备份了我的旧计算机,并使用该备份恢复了新计算机。 So in essence all my data and profile from old transferred to new. 所以从本质上我所有的数据和配置文件从旧转移到新的。 To me it was pretty transparent. 对我而言,它非常透明。 Basically, I was moving from a mac pro to mac air. 基本上,我是从mac pro转移到mac air。 All my git repos transferred too without any problems. 我所有的git repos也没有任何问题。 I have a feeling Windows image would work similarly but to be honest I haven't done one myself. 我有一种感觉Windows图像会起作用,但说实话,我自己没有做过。 Hope this helps. 希望这可以帮助。

After copying your files from the old machine to the new, one needs to tell the GitHub app where your local files (repo) are.将文件从旧机器复制到新机器后,需要告诉 GitHub 应用程序您的本地文件(repo)在哪里。

In the GitHub app go to [File\Add local repository...] or Ctrl+O .在 GitHub 应用程序 go 中到[File\Add local repository...]Ctrl+O Then you browse to the local folder with your repo.然后你用你的 repo 浏览到本地文件夹。 As explained by @user41871, git repos are self-contained so GitHub will detect your repo in the local files and sync appropriately to your remote repo in GitHub.正如@user41871 所解释的,git 存储库是独立的,因此 GitHub 将在本地文件中检测到您的存储库,并适当地同步到 GitHub 中的远程存储库。

Make sure you've installed Git before turning to GitHub.在转向 GitHub 之前,请确保您已经安装了 Git。 The GitHub app does not come with Git. GitHub 应用程序不附带 Git。 Surprisingly the GitHub app 'works' even when Git is not installed.令人惊讶的是,即使未安装 Git,GitHub 应用程序也能“工作”。

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

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