Git:"git clone"的最佳做法是什么?到现有文件夹中? [英] Git: What's the best practice to "git clone" into an existing folder?

查看:64
本文介绍了Git:"git clone"的最佳做法是什么?到现有文件夹中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目的工作副本,没有任何源代码控制元数据.现在,我想在此文件夹中执行与git-clone等效的操作,并保留本地更改.

I have a working copy of the project, without any source control meta data. Now, I'd like to do the equivalent of git-clone into this folder, and keep my local changes.

git-clone不允许我克隆到现有文件夹中.最佳做法是什么?

git-clone doesn't allow me to clone into an existing folder. What is the best practice here?

推荐答案

这可以通过以下步骤完成:克隆到新目录,然后将 .git 目录移动到现有目录中.

This can be done by cloning to a new directory, then moving the .git directory into your existing directory.

如果现有目录名为代码".

If your existing directory is named "code".

git clone https://myrepo.com/git.git temp
mv temp/.git code/.git
rm -rf temp

这也可以在克隆命令期间不执行检出操作来完成;可以在此处中找到.

This can also be done without doing a checkout during the clone command; more information can be found here.

这篇关于Git:"git clone"的最佳做法是什么?到现有文件夹中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆