server-side:
- navigate to your user folder /home/username/
- create a folder for your repo. 'repo'
- create a folder inside of your repo. call it whatever. 'test'
- cd into folder.
- git init --bare
local:
-
navigate to local repo
-
test ssh connection to the server ex. "ssh [email protected] 'echo it worked'"
-
if it fails:
-
navigate to project root .ssh folder
-
copy contents of id_rsa.pub file
-
on server, navigate to git .ssh folder
-
paste local ssh key into "authorized_keys" folder
-
on local, try the ssh command again, should work now.
-add ssh address to remotes for folder where you initialized the bare repository, call it staging/production or whatever ex. "git remote add staging ssh://[email protected]/home/username/repo/test"
-
add files to local commit. just make a random file if it's empty or change an existing one if there's already stuff there that hasn't changed.
-
commit
-
run command below replace staging with whatever you called your remote
-
git push staging +master:refs/heads/master -- this only applies the first time. Afterwords you can just push staging master.
server-side:
- navigate to the folder that holds the bare repo. 'test'
- navigate into "hooks" folder
- create a new file called post-receive with the following contents where GIT_WORK_TREE url points to the folder for your repo. 'repo' :
#!/bin/sh
GIT_WORK_TREE=/home/username/repo
export GIT_WORK_TREE
git checkout -f
- save that file as post-receive
- make file executable with the following command... "chmod +x post-receive"
local:
- make a change to one of the files in your repo, commit file, then push to your remote server 'staging'
- changes should now appear automagically in your remote repo as well :D