Git克隆到当前目录

che*_*505 16 git

我正在尝试将存储库克隆到我当前的目录中.但是,当我使用此命令克隆它时:

git clone REPOURL .
Run Code Online (Sandbox Code Playgroud)

它说:

fatal: destination path '.' already exists and is not an empty directory.
Run Code Online (Sandbox Code Playgroud)

我克隆的文件夹已经存在,我只想添加我在git repo中的文件.

有什么方法可以做到这一点吗?

谢谢

Cod*_*ard 28

您不需要克隆存储库,您需要添加远程,然后将文件添加到存储库.

git init
git remote add origin <remote_url>
git fetch --all --prune
git checkout master
git add -A .
git commit -m "Adding my files..."
Run Code Online (Sandbox Code Playgroud)

详情如下:

您已经有一个远程存储库,并且您希望将文件添加到此存储库.

  1. 首先,你必须"告诉"git当前目录是一个git存储库
    git init

  2. 然后你需要告诉git什么是远程存储库的url
    git remote add origin <remote_url>

  3. 现在您需要获取远程存储库的内容(所有内容 - 分支,标签等) git fetch --all --prune

  4. 检查所需的分支(本例中为master)
    git checkout <branch>

  5. 将新文件添加到当前 <branch> git add -A .

  6. 提交您的更改 git commit

  7. 将更改上载回远程存储库 git push origin <branch>