如果我将代码下载为zip,可以连接git吗? [英] Can I connect git if I downloaded the code as zip
问题描述
我以zip格式下载了最新的存储库代码,但现在我也希望能够使用分支。
I downloaded the latest code of a repositiry as zip but now I want to be able to work with branches too.
无论如何,我是否可以像使用克隆项目一样将文件夹用作git存储库?
Is there anyway I can use the folder as a git repository just like what I have if I clone the project?
推荐答案
我遇到了类似的问题。
TL; DR短版相关命令:
TL;DR short version relevant commands:
git init
git remote add origin git@github.com:somecompany/some-repo.git
git add .
git pull origin master
全文:我在克隆存储库时遇到了麻烦,所以最终下载并展开了zip。我做了 git init
之后, git status
显示了:
Full story: I was having trouble cloning the repo so I eventually downloaded and expanded the zip instead. I did git init
after which git status
showed:
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添加了原点git remote add origin git@github.com:somecompany / some-repo.git
我做了 git提取
,它获取了远程分支机构的信息。
I did a git fetch
which got the remote's branches info.
当我做了 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
我尝试了几项无济于事的事情,最后我做到了:
I tried several things that didn't help, finally I did:
git add。
文件现在都已上演但是我没有提交。相反,我做了:
the files were all staged now but I did NOT make a commit. Instead I did:
git pull origin master
,它输出:
From github.com:somecompany/some-repo
* branch master -> FETCH_HEAD
现在当我执行 git status
时,报告:
Now when I did git status
it reported:
On branch master
nothing to commit, working tree clean
我很好。
这篇关于如果我将代码下载为zip,可以连接git吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!