简体   繁体   English

在拇指驱动器上克隆 git 存储库

[英]cloning git repository on thumbdrive

I already have a local workig space repository in /applications/mamp/htdocs/myproject/.git and i can't figure out how to clone it onto a folder in my thumbdrive and use that as my remote to push to.我已经在 /applications/mamp/htdocs/myproject/.git 中有一个本地工作空间存储库,我不知道如何将它克隆到我的拇指驱动器中的一个文件夹中,并将其用作我的遥控器来推送。

do i have to create a bare git repository in the directory on my folder first?我是否必须首先在我的文件夹的目录中创建一个裸 git 存储库? and then clone my working space one to it?然后将我的工作空间克隆到一个呢?

or do i just cd into my directory on my thumbdrive(with no.git directory) and clone the working space repo to it which would automatically create the.git repo on the thumbdrive?还是我只是 cd 进入我的拇指驱动器上的目录(没有.git 目录)并将工作空间存储库克隆到它,这将自动在拇指驱动器上创建.git 存储库?

i'm confused on the proper steps to use my thumbdrive as my remote repo我对使用拇指驱动器作为远程仓库的正确步骤感到困惑

my thumbdrive's path is "volumes/thumbdrive/"我的拇指驱动器的路径是“volumes/thumbdrive/”

now i'm trying to add my remote but i can't seem to get the path right i guess...现在我正在尝试添加我的遥控器,但我想我似乎无法找到正确的路径......

David-Adamss-MacBook-Pro:myproject davidadams$ git remote add flashstick /volumes/thumbdrive/repo/.git
David-Adamss-MacBook-Pro:myproject davidadams$ git remote
flashstick
thumdrive
David-Adamss-MacBook-Pro:myproject davidadams$ git push flashstick master
fatal: '/volumes/thumbdrive/repo/.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

and this didn't work either这也不起作用

David-Adamss-MacBook-Pro:myproject davidadams$ git remote add flashdrive /volumes/thumbdrive/repo
David-Adamss-MacBook-Pro:myproject davidadams$ git remote
flashdrive
flashstick
thumdrive
David-Adamss-MacBook-Pro:myproject davidadams$ git push flashdrive master
fatal: '/volumes/thumbdrive/repo' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
David-Adamss-MacBook-Pro:myproject davidadams$ 

Clone the local repository into your volumes/thumbdrive and then setup remotes to this newly cloned repo from the old one将本地存储volumes/thumbdrive器中,然后将远程设置为从旧版本克隆到这个新克隆的存储库

`git remote add thumbdrive volumes/thumbdrive`

The remote name after above would be thumbdrive ( use origin if you want ) and you can push like上面之后的远程名称将是thumbdrive器(如果需要,请使用原点),您可以像这样推送

`git push thumbdrive master`

Another approach:另一种方法:

Copy / move /applications/mamp/htdocs/myproject/.git to the thumbdrive and then clone it back to the desired location./applications/mamp/htdocs/myproject/.git复制/移动到拇指驱动器,然后将其克隆回所需位置。

The best way to do this is to cd to /volumes/thumbdrive/repo directory and then:最好的方法是 cd 到 /volumes/thumbdrive/repo 目录,然后:

git clone --bare /applications/mamp/htdocs/myproject/

This will clone the repo, but won't make any working copies on the thumbdrive.这将克隆存储库,但不会在拇指驱动器上制作任何工作副本。 If you look at the remote, you'll see one directory created, called myproject.git, which is probably what you want.如果您查看遥控器,您会看到创建了一个名为 myproject.git 的目录,这可能就是您想要的。

Then from your local git repo:然后从您当地的 git 回购:

git remote add thumbdrive /volumes/thumbdrive/repo/myproject.git

After you make changes, you can:进行更改后,您可以:

git push thumbdrive master

Go to volumes/thumbdrive/ , then: Go 到volumes/thumbdrive/ ,然后:

git clone /applications/mamp/htdocs/myproject/

From then on, you can just push things to volumes/thumbdrive , or pull from /applications从那时起,您可以将内容push送到volumes/thumbdrive ,或从/applications拉取

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

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