如何删除或更改本地计算机上克隆的 git 存储库的目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5667106/
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-10 10:37:07  来源:igfitidea点击:

How to delete or change directory of a cloned git repository on a local computer

gitwindows-xpmove

提问by GitNewb

Used git clone [url]to clone an open source project but it cloned to the

用于git clone [url]克隆一个开源项目,但它克隆到

C:\Documents and Setings\$USER\project

C:\Documents and Setings\$USER\project

What I wanted to do is clone the project to C:\project. I don't want to have duplicate project clones on my local machine.

我想做的是将项目克隆到C:\project. 我不想在我的本地机器上有重复的项目克隆。

How do I go about moving it to that location or deleting the existing repository(hopefully that's a correct term) and cloning it again?

我如何将它移动到那个位置或删除现有的存储库(希望这是一个正确的术语)并再次克隆它?

I assume after deleting I should use something like the following to clone it to the desired location?

我假设删除后我应该使用类似以下内容将其克隆到所需位置?

$ git clone [url] C:\project

$ git clone [url] C:\project

回答by deanWombourne

Just move it :)

只需移动它:)

command line :

命令行 :

move "C:\Documents and Setings$USER\project" C:\project

or just drag the folder in explorer.

或者只是在资源管理器中拖动文件夹。

Git won't care where it is - all the metadata for the repository is inside a folder called .gitinside your project folder.

Git 不会关心它在哪里 - 存储库的所有元数据都位于.git项目文件夹内的一个文件夹中。

回答by tbthorpe

You can just delete that directory that you cloned the repo into, and re-clone it wherever you'd like.

您可以删除将 repo 克隆到的目录,然后在您想要的任何位置重新克隆它。

回答by deanflory

You could try this via SSH: rm -rf foldernamehere

您可以通过 SSH 尝试此操作: rm -rf foldernamehere

回答by Paul

I'm assuming you're using Windows, and GitBASH.

我假设您使用的是 Windows 和 GitBASH。

You can just delete the folder "C:...\project" with no adverse effects.

您可以删除文件夹“C:...\project”而不会产生负面影响。

Then in git bash, you can do cd c\:. This changes the directory you're working in to C:\

然后在 git bash 中,您可以执行cd c\:. 这会将您正在工作的目录更改为 C:\

Then you can do git clone [url]This will create a folder called "project" on C:\ with the contents of the repo.

然后你可以这样做git clone [url]这将在 C:\ 上创建一个名为“project”的文件夹,其中包含 repo 的内容。

If you'd like to name it something else, you can do git clone [url] [something else]

如果你想给它起别的名字,你可以这样做 git clone [url] [something else]

For example
cd c\:
git clone [email protected]:username\repo.git MyRepo

例如
cd c\:
git clone [email protected]:username\repo.git MyRepo

This would create a folder at "C:\MyRepo" with the contents of the remote repository.

这将在“C:\MyRepo”创建一个文件夹,其中包含远程存储库的内容。

回答by Naveen Mittal

  1. Go to working directory where you project folder (cloned folder) is placed.
  2. Now delete the folder.
  3. in windows just right click and do delete.
  4. in command line use rm -r "folder name"
  5. this worked for me
  1. 转到放置项目文件夹(克隆文件夹)的工作目录。
  2. 现在删除文件夹。
  3. 在 Windows 中只需右键单击并删除。
  4. 在命令行中使用 rm -r "文件夹名称"
  5. 这对我有用