My intended goal:
I maintain some files in my local computer, and I also share them with others by putting them on my website. In the past I did this by manually uploading all the files using FTP, every time I did some modifications etc. Now, I am wondering if I can use Git to help me achieve this (by "pushing" the local files to my website server). My server is hosted by Dreamhost.
First Attempt:
First, I try this tutorial. I first push my local files to my Github repo, and ssh into my Dreamhost server to git clone --bare
from the Github repo. But I find that git does not transfer my files. So I ignore the tutorial.
Second Attempt:
I ssh
into my Dreamhost server to clone directly from Github. My files are all transfered to the server. Then, on my local computer, I git remote add dreamhost ssh://[email protected]/~/my-project
. Then I add some files, and commit, and git push dreamhost master
. And a bunch of errors appear:
(source: geotakucovi.com)
As a newbie Git user, I must have missed something. Please help!
When you are using a Git repository as a central repo (as you seem to be), you generally should not have a working directory on that repo. The reason for this is listed in the error you mentioned: pushing into a branch which is checked out can cause the working tree to become out of sync.
If the people you are sharing with can use Git, then you instead can set up a bare repository on the server, then push to it.
If they cannot use Git, then you'll need a slightly more complicated workflow:
After this step, then the files should be available under
/project
I'm not a huge git user, but try this: