How to copy a local repository to remote server using git?

git

Solution

You've created a remote repository without a working directory (which is the purpose of the `--bare` option). What you need to do next is clone that remote repository into your website directory. I use the same approach; I have a ~/git directory with one or more bare git repositories and then clones for one or more web sites. Your steps could be:

# locate your bare repository in a 'git' directory
remote$ mkdir ~/git; mkdir ~/git/mywebsite.git; cd ~/git/mywebsite.git; git init --bare

# set this up as your remote
local$ git remote add origin ssh:.../git/mywebsite.git
local$ git push origin ...

# on the remote, clone into your working website
remote$ cd ~/public_html
remote$ git clone ~/git/mywebsite.git mywebsite

Using this approach you can develop locally, push to remote as often as you like and then, when you are ready, `git pull` on the remote to actually update the website.

Problem

I'm trying to use git to deploy my local code in my remote server. So here is what I've done in my local folder mywebsite/ : ``` git init git add . git commit -m "Initial commit" ``` Then, on my web server : ``` mkdir ~/public_html/myrepo.git cd myrepo.git git init --bare ``` Then, on my local folder mywebsite/ : ``` git remote add remote_mywebsite ssh://user@domain.com:port/~/public_html/myrepo.git git push remote_mywebsite master ``` which gave this result : ``` Counting objects: 89, done. Delta compression using up to 4 threads. Compressing objects: 100% (74/74), done. Writing objects: 100% (89/89), 61.94 KiB, done. Total 89 (delta 2), reused 0 (delta 0) To ssh://user@domain.com:8943/~/public_html/myrepo.git * [new branch] master -> master git pull remote_mywebsite ``` But when I log in to my web server, in the myrepo.git, I'm still having these files and folders ``` ./ ../ branches/ config description HEAD hooks/ info/ objects/ refs/ ``` and I don't retrieve the files and folders I have in my local mywebsite folder. How could I retrieve my code in the remote myrepo.git folder ? Did I do something wrong ? Thanks a lot for your help!

Original source