(this is you connecting to your remote server)
ssh username@xxx.xxx.xxx.xxx
(this gets you to the 'absolute root' of the server)
cd ../
(navigate to the directory one level above your website directory - e.g. your website directory being where you would upload your HTML files etc)
cd www/..../
Note: if (for example) your web directory is httpdocs then move up one level from there. The following example assumes httpdocs is your web directory...
(initiate new git repo)
git init
(jump back up a directory level)
cd ../
The following three commands are the black magic for getting a remote git repo setup:
git clone --bare httpdocs my_project.git
add remote to repository, path has to be the path of bare directory. navigate to working directory
git remote add origin /www/my_project.git
create a branch
git checkout -b master
add files
git add .
commit and push
git commit -m 'initial commit'
git push origin master
navigate to working directory and see remote
git remove -v
add remote on sourcetree on your laptop
username@hostname:/www/htdocs/my_project.git
in order for changes to be pulled into working directory, edit my-project.git hooks/post-update.sample to:
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
#exec git update-server-info
cd ~/path/to/working-directory || exit
unset GIT_DIR
git pull origin master
rename post-update.sample to post-update
mv post-update.sample post-update