简体   繁体   中英

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. 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}/
  • You're moving to {project_path}/../../ , which is two directories up from where {project_path} is. Is this correct?

This should achieve what is probably your intention: (Getting a .git that's linked to bitbucket into your local folder.)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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