如果我将代码下载为 zip,我可以连接 git

Ami*_*mit 12 git cloning

我将存储库的最新代码下载为 zip,但现在我也希望能够使用分支。

无论如何,我可以像克隆项目一样使用该文件夹作为 git 存储库吗?

ced*_*dlb 14

我有一个类似的问题。

TL;DR 短版相关命令:

git init
git remote add origin git@github.com:somecompany/some-repo.git
git add .
git pull origin master
Run Code Online (Sandbox Code Playgroud)

全文:我在克隆 repo 时遇到了麻烦,所以我最终下载并扩展了 zip。我做了git init之后git status显示:

On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    .gitignore
    .rspec
    .ruby-version
    ...(all the directories of the project)...

nothing added to commit but untracked files present (use "git add" to track)
Run Code Online (Sandbox Code Playgroud)

然后我添加了原点 git remote add origin git@github.com:somecompany/some-repo.git

我做了一个git fetch获取遥控器分支信息的操作。

我做的git pull origin master时候说:

From github.com:somecompany/some-repo
 * branch            master     -> FETCH_HEAD
error: The following untracked working tree files would be overwritten by merge:
    .gitignore
    .rspec
    .ruby-version
    ...(all the files of the project)...
Please move or remove them before you merge.
Aborting
Run Code Online (Sandbox Code Playgroud)

我尝试了几件没有帮助的事情,最后我做到了:

git add .

这些文件现在都已上演,但我没有提交。相反,我做了:

git pull origin master 哪个输出:

From github.com:somecompany/some-repo
 * branch            master     -> FETCH_HEAD
Run Code Online (Sandbox Code Playgroud)

现在,当我这样做时,git status它报告了:

On branch master
nothing to commit, working tree clean
Run Code Online (Sandbox Code Playgroud)

我很高兴去。


小智 -1

您可以粘贴 git 配置文件并正确设置远程 URL。您可以开始拉推。快乐编码