简体   繁体   English

如果已经存在git repo,我可以克隆它吗?

[英]Can I clone a git repo if it already exists?

I've started to use git 'properly' now so I have websites that use git repo's that I downloaded as zip files and uploaded to my server manually. 我现在已经开始适当地使用git,因此我有一些网站使用git repo,这些网站已作为zip文件下载并手动上传到我的服务器。

Now I know to just clone to repo using SSH and then update via SSH. 现在我知道只需使用SSH克隆即可进行回购,然后通过SSH进行更新。

So if I have a repo on my server, is there a command I can run to apply the .git directory etc? 因此,如果我的服务器上有一个存储库,是否可以运行一个命令来应用.git目录等? From then on I will be able to update via SSH rather than downloading a repo manually and uploading via FTP. 从那时起,我将能够通过SSH进行更新,而不是手动下载存储库并通过FTP上传。

If you got a working copy with .git inside, all you need to do is to add a "remote link" via git remote : 如果您有一个带有.git的工作副本,那么您要做的就是通过git remote添加一个“远程链接”:

git remote add <name> <url>

Then you can send/receive commits via git pull / git push 然后您可以通过git pull / git push发送/接收提交

git clone is basically does three things: git init, remote add and pull. git clone是做三件事:git init,远程添加和拉取。

If I understand correctly, you just want to clone a repo, make some changes, and push your changes back to the repo? 如果我理解正确,您只是想克隆一个仓库,进行一些更改,然后将您的更改推回该仓库? That's really easy to do. 这真的很容易做到。

git clone ssh://foo
cd foo
... Make some changes
git status # See you changes
git add -u # Add all changes
git commit # Make a new commit
git push origin # Push your commit to the remote (called origin by default)

From this point on, you can continue to pull changes from the server with git pull and push your commits with git push . 从这一点开始,您可以继续使用git pull从服务器获取更改,并使用git push推送您的提交。

Sounds like you're pretty new to Git. 听起来您是Git的新手。 You should read the documentation and perhaps find a good tutorial to work through. 您应该阅读文档,并可能找到一个很好的教程来进行学习。

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

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