Skip to content

Instantly share code, notes, and snippets.

@trbsi
Last active September 7, 2016 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trbsi/8ed0e979f018fc437db1bf22450ef825 to your computer and use it in GitHub Desktop.
Save trbsi/8ed0e979f018fc437db1bf22450ef825 to your computer and use it in GitHub Desktop.

(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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment