简体   繁体   English

从终端git clone,然后将内容移到非空文件夹

[英]from terminal git clone, then move contents to non-empty folder

I'm trying to create a workflow where I create my local project, automatically create the remote bitbucket repo based on the project name, then clone that repo into the local folder I'm working from. 我正在尝试创建一个工作流,在其中创建我的本地项目,根据项目名称自动创建远程bitbucket存储库,然后将该存储库克隆到我正在使用的本地文件夹中。 The problem is, you can't clone into a folder with files. 问题是,您无法克隆到包含文件的文件夹中。 The workaround so far is to clone into a folder, then move the contents into my working directory. 到目前为止,解决方法是克隆到文件夹中,然后将内容移动到我的工作目录中。

This is what I have so far that's not working: 到目前为止,这是行不通的:

git clone https://U:P@bitbucket.org/user-account/{project_name}.git &  mv {project_path}/{project_name}/.git {project_path}/../../

A few problems: 一些问题:

  • Multiple interdependent commands should be delimited with && , not & 多个相互依赖的命令应使用&&分隔,而不是&
  • You're cloning to the current directory, but moving from under {project_path}/ 您正在克隆到当前目录,但是从{project_path}/下移动
  • You're moving to {project_path}/../../ , which is two directories up from where {project_path} is. 您将移至{project_path}/../../ ,这是{project_path}所在位置的两个目录。 Is this correct? 这个对吗?

This should achieve what is probably your intention: (Getting a .git that's linked to bitbucket into your local folder.) 这应该可以实现您的意图:(将与bitbucket链接的.git放入本地文件夹。)

git clone https://U:P@bitbucket.org/user-account/{project_name}.git --no-checkout tmp
mv tmp/.git {path_to_your_local_folder}/
rmdir tmp

How do you "automatically make a bitbucket repository"? 您如何“自动创建一个位桶存储库”?

The normal workflow is to make a bitbucket repository through their site. 正常的工作流程是通过其站点创建一个位桶存储库。 Now you can do the rest of the steps without a clone. 现在,您无需克隆即可执行其余步骤。

git init
cat > .gitignore # add the patterns you don't want tracked
git add -A
git commit -m "initial commit"
git remote add origin <the url to your bitbucket repo>
git push origin master

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

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