简体   繁体   English

将git仓库克隆到现有的非空目录中

[英]Clone a git repository into a existing non-empty directory

What is the best practice to clone a Git repository into an existing directory which already includes some other files and folders? 将Git存储库克隆到已经包含其他文件和文件夹的现有目录中的最佳实践是什么?

I have created 2 branches dev and master and locally working on dev branch. 我创建了两个分支devmaster并在本地工作于dev分支。 So I want to clone master branch in www folder which is the root of a website. 所以我想在网站根目录www文件夹中克隆master分支。 Then at regular times I want to merge dev branch into master . 然后在常规时间我想将dev分支合并到master

Now the problem is that I can't delete www director because it has essential contents. 现在的问题是我无法删除www导演,因为它具有必不可少的内容。 I also can't rename or move it. 我也无法重命名或移动它。

Is there a way to fully clone the master branch into the root of www directory without renaming or deleting it's content? 有没有一种方法可以将master分支完全克隆到www目录的根目录,而无需重命名或删除其内容?

Is there a way to fully clone the master branch into the root ofwww directory without renaming or deleting it's content? 有没有一种方法可以将master分支完全克隆到www目录的根目录而不重命名或删除其内容?

Clone the repo elsewhere (in master branch), then move the checked out files and the .git folder to the existing www/ folder. 将存储库克隆到其他位置(在master分支中),然后将检出的文件和.git文件夹移至现有的www/文件夹。

You might have to add the existing www/ files in your .gitignore . 您可能必须在.gitignore添加现有的www/文件。

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

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