git 将 Github 存储库克隆到特定的 Windows 文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13967353/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:54:37  来源:igfitidea点击:

Clone Github repo to specific Windows folder?

gitgithubgithub-for-windows

提问by HP.

How to change the cloning folder of a specific git? My default storage directoryis here

如何更改特定 git 的克隆文件夹?我的默认存储目录在这里

C:\Users\myPC\Documents\GitHub

But for this one git

但是对于这个 git

https://github.com/username/myproject

I want to put it in

我想放进去

C:\somefolder

(and notlike C:\somefolder\myprojectbut all the files under C:\somefolder)

(而不是C:\ somefolder \ myproject的,但下的所有文件C:\ somefolder

How to do that? I tried git clonecommand line but then the git doesn't show up in my Github for Windows client

怎么做?我尝试了git clone命令行,但 git 没有出现在我的 Github for Windows 客户端中

Sorry for basic question but couldn't google or search here any answer!

抱歉基本问题,但无法谷歌或在这里搜索任何答案!

采纳答案by Nevik Rehnel

After you have manually cloned the repository with git clone, you can manually Add a local repositoryto Github for Windows (I can't take a screenshot right now because I'm on another machine, but it should be relatively easy to find). I honestly don't know, though, if this will then have the full set of features (i.e. if GhfW recognizes it as a Github clone), or if it will have the reduced "regular" set for repositories in general.

使用 手动克隆存储库后git clone,您可以手动Add a local repository到 Windows 版 Github(我现在无法截取屏幕截图,因为我在另一台机器上,但应该相对容易找到)。不过,老实说,我不知道这是否会有完整的功能集(即,如果 GhfW 将其识别为 Github 克隆),或者它是否会为存储库设置减少的“常规”设置。

As always: Try it and see! :D

一如既往:试试看!:D

回答by Anuj Mehta

In "GitHub for Windows" first go to Tools-->Options Here select your folder in "default storage directory". Now in GitHub if you click on "Clone in Desktop" button then it will clone in selected folder

在“GitHub for Windows”中,首先转到“工具”-->“选项”,在“默认存储目录”中选择您的文件夹。现在在 GitHub 中,如果您单击“在桌面中克隆”按钮,它将克隆到选定的文件夹中

回答by AmeliaBR

Another option that I've tried is to use the "Create repo" command to create an (empty) repository in the folder of your choice, and then hook it up to Github by:

我尝试过的另一个选项是使用“Create repo”命令在您选择的文件夹中创建一个(空)存储库,然后通过以下方式将其连接到 Github:

  1. Opening the repository settings (click the cog on the top right, select "Repository settings...")
  2. Copying and pasting the HTTPS clone URL from the Github page (in the right sidebar) into the field that says "Primary remote (origin)"
  3. Sync the repo with the newly attached origin. You may need to open it in shell to get it to work without errors.
  1. 打开存储库设置(单击右上角的齿轮,选择“存储库设置...”)
  2. 将 HTTPS 克隆 URL 从 Github 页面(在右侧边栏中)复制并粘贴到显示“主要远程(来源)”的字段中
  3. 将 repo 与新附加的原点同步。您可能需要在 shell 中打开它才能使其正常工作而不会出错。

Why Github doesn't make this easier, I do not know. Two years after this question was posted, and it's still a hassle. It's nice to have a default storage directory, but it's also nice to have a "Where do you want to save this?" option.

为什么 Github 没有让这更容易,我不知道。这个问题发布两年后,仍然很麻烦。有一个默认的存储目录很好,但有一个“你想把它保存在哪里?”也很好。选项。

Finally, if you do clone a repo into the wrong place, and want to move it somewhere else:

最后,如果你确实将一个 repo 克隆到了错误的地方,并且想把它移到其他地方:

  1. Open up the repo in Explorer (if you're not sure where it is on your local file system, use the "Open in Explorer" option from the little cog icon on Github for Windows).
  2. Cut and paste the entirefolder to wherever you want it to be.
  3. Go back to Github for Windows. It will now give you an error message that it cannot locate the repository. Select the "Locate" option, and find the folder's new location yourself.
  1. 在资源管理器中打开存储库(如果您不确定它在本地文件系统上的位置,请使用 Windows 版 Github 上的小齿轮图标中的“在资源管理器中打开”选项)。
  2. 整个文件夹剪切并粘贴到您想要的任何位置。
  3. 返回 Windows 版 Github。它现在会给您一条错误消息,指出它无法找到存储库。选择“定位”选项,然后自己找到文件夹的新位置。

This might actually be the easiest option for getting the repo where you want it.

这实际上可能是在您想要的位置获取 repo 的最简单选择。

回答by KalenGi

The latest GitHub desktop client (3.3.4.0) prompts for a local directory to clone the repo to. This was when cloning my own repo from github.com to local.

最新的 GitHub 桌面客户端 (3.3.4.0) 提示输入本地目录以将存储库克隆到。这是将我自己的 repo 从 github.com 克隆到本地时。

回答by stochastiker

Just change the working directory in git bash by the cdcommand. Once that is done you can check if the directory you want to download/clone your git repo pwdcommand. Now you can clone the repo into the desired folder. As usual use git cloneto clone the Repository.

只需通过cd命令更改 git bash 中的工作目录。完成后,您可以检查是否要下载/克隆 git repopwd命令的目录。现在您可以将 repo 克隆到所需的文件夹中。像往常一样用于git clone克隆存储库。

Hope this helps.

希望这可以帮助。

回答by Andre Figueiredo

I've downloaded recently GitHub for Windows and it didn't come with option Add a local repository.

我最近下载了适用于 Windows 的 GitHub,但它没有附带 option Add a local repository

I had to cloneand delete the folderin Windows Explorer.
The program gives and error for this repository and the option to locate the new folder or remove.
Locatethe folder to which one that you want.

我不得不在 Windows 资源管理器中克隆删除该文件夹
该程序给出了此存储库的错误以及定位新文件夹或删除的选项。
找到您想要的文件夹。