NT78SEO
NT78SEO

Reputation: 21

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.

Upvotes: 1

Views: 2228

Answers (2)

myaut
myaut

Reputation: 11504

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.

Upvotes: 3

mkasberg
mkasberg

Reputation: 17292

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.

Upvotes: 0

Related Questions