简体   繁体   中英

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.

Now I know to just clone to repo using SSH and then update via SSH.

So if I have a repo on my server, is there a command I can run to apply the .git directory etc? From then on I will be able to update via SSH rather than downloading a repo manually and uploading via 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 remote add <name> <url>

Then you can send/receive commits via git pull / git push

git clone is basically does three things: git init, remote add and pull.

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 .

Sounds like you're pretty new to Git. You should read the documentation and perhaps find a good tutorial to work through.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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