Sunday, March 9, 2014

Publishing to NSF via git

(This is another of those safe-keeping posts aimed at backing up some information that I find useful. I got the information from here, but I never know if/when that page will go away.)

I use for my domain and web hosting. I use git for storing my repositories and managing my own codebases. Both are handy and affordable. This post explains how to set up an NFS site with git so that I can publish changes to my website quickly and easily via a command line push command. (It is worth noting that any configuration that is specific to the web server, whether localhost or your public facing site,  should be in a separate config file that does not get updated by git. In other words, put all of your client-side configuration data into a separate file and list that file in your .gitignore file.)

So here it goes:

  1. SSH into your NFS account from the command line:

  2. Run the following commands within the folder where you want your git repo files to end up. (If you are just updating a subdirectory and not your top level folder, then cd into the appropriate directory before doing the following:

    mkdir .git cd .git git init --bare cd hooks touch post-receive pico post-receive
  3. Add the following line to the file you opened in pico. Again, if you are in a sub-directory, you will need to indicate that in the followling line by extending the path beyond the public folder:
    GIT_WORK_TREE=/home/public git checkout -f
  4. Save and exit the file, then run the following to set appropriate permissions on the file:

    chmod +x post-receive
  5. You can now exit out of your SSH session. Back in your local repo git folder run the following to set up a new remote for this repo. 'website' is an arbitrary remote name which you could set to whatever you want:

    git remote add website ssh://
  6. Now you are all set up. When you are ready to publish your files to NFS, simply do a push as if to github, but push instead to the website:
    git push website master

That's all there is to it.  Piece of cake.

1 comment:

Anonymous said...

Создание сайта будь то сайт – визитка, корпоративный сайт, [url=]продвижение сайта[/url], интернет магазин или мощный портал проходит в несколько этапов.
Создание сайта - как выбрать правильный домен