gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 14:12:07 24 4
gpt4 key购买 nike

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

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

最佳答案

我有一个类似的问题。

TL;DR 短版相关命令:

git init
git remote add origin git@github.com:somecompany/some-repo.git
git add .
git pull origin master

全文:我在克隆 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)

然后我添加了原点 git remote add origin git@github.com:somecompany/some-repo.git
我做了一个 git fetch它得到了 Remote 的分支信息。

当我做 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

我尝试了几件没有帮助的事情,最后我做到了:
git add .
这些文件现在都已上演,但我没有提交。相反,我做了:
git pull origin master哪个输出:
From github.com:somecompany/some-repo
* branch master -> FETCH_HEAD

现在当我做 git status它报告说:
On branch master
nothing to commit, working tree clean

我很高兴去。

关于git - 如果我将代码下载为 zip,我可以连接 git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34354086/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com