Website Version Control: Difference between revisions
Website Version Control |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
We are bringing the static and custom files on the website into Git to version control them. They are in this repository: | {{Cleanup}} | ||
We are bringing the static and custom files on the [[website]] into Git to version control them. They are in this repository: | |||
https://github.com/NottingHack/website | https://github.com/NottingHack/website | ||
Line 9: | Line 10: | ||
==== Set up Git on the Web Server ==== | ==== Set up Git on the Web Server ==== | ||
Many instructions on the web suggest setting up the apache user a SSH key to do passwordless git (such as https://github.com/settings/ssh), but instead we will use the git read only URL: | |||
<pre>git://github.com/NottingHack/website.git</pre> | |||
Seeing as we never need to commit from the webserver, this should be fine. | |||
So all we need to do is ensure Git is installed, and configured. | |||
==== Pull the remote repository ==== | ==== Pull the remote repository ==== | ||
Once the repository on | Once the repository on Github is set up and populated, we need to set up the server to pull from it, without deleting loads of things off the server. We can't just do a | ||
<pre>git clone</pre> | <pre>git clone</pre> | ||
Line 24: | Line 32: | ||
<pre>*</pre> | <pre>*</pre> | ||
This tells git to ignore (and overwrite) any files it likes. It also won't ever complain about untracked files during a commit (although we won't be commiting from here anyway). '''DANGER''' do not so this on a local filesystem, unless you like losing files. | This tells git to ignore (and overwrite) any files it likes. It also won't ever complain about untracked files during a commit (although we won't be commiting from here anyway). '''DANGER''' do not so this on a local filesystem, unless you like losing files. '''Don't commit''' the .gitignore file to the repository, or you will mess up everyone's computer! | ||
Now set the main directory as a git repository | Now set the main directory as a git repository | ||
Line 44: | Line 52: | ||
==== Set up the Update Hook ==== | ==== Set up the Update Hook ==== | ||
In the Admin section of the repository, we add the URL of the deploy script to the "WebHook URLs" section. These are the post-receive hooks and each URL will be POSTed to when the repository is updated. | |||
[[Category:Website]] | [[Category:Website]] |
Latest revision as of 20:53, 15 December 2018
This page requires cleaning up! Describe the specific problem using the 'reason' parameter (See Cleanup template for instructions). Please help improve this page if you can. Use the talk page to discuss suggestions. |
We are bringing the static and custom files on the website into Git to version control them. They are in this repository:
https://github.com/NottingHack/website
None of the Wordpress or Wiki system files are included in the repository, this allows those systems to be updated automatically, without engaging the version control.
Setting up
Set up Git on the Web Server
Many instructions on the web suggest setting up the apache user a SSH key to do passwordless git (such as https://github.com/settings/ssh), but instead we will use the git read only URL:
git://github.com/NottingHack/website.git
Seeing as we never need to commit from the webserver, this should be fine.
So all we need to do is ensure Git is installed, and configured.
Pull the remote repository
Once the repository on Github is set up and populated, we need to set up the server to pull from it, without deleting loads of things off the server. We can't just do a
git clone
as git will complain about untracked files, overwriting, etc. So we need to be a bit sneaky about it.
We are going to be doing this in the main directory (above public_html) as we are also tracking files outside the webroot
First, we create a .gitignore file in the main directory, with just these contents:
*
This tells git to ignore (and overwrite) any files it likes. It also won't ever complain about untracked files during a commit (although we won't be commiting from here anyway). DANGER do not so this on a local filesystem, unless you like losing files. Don't commit the .gitignore file to the repository, or you will mess up everyone's computer!
Now set the main directory as a git repository
git init
Then add the remote
git remote add origin git@github.com:NottingHack/website.git
Pull the data from git (this won't change any files yet).
git pull
Finally, make a new master branch and set it to track the origin master. This will overwrite any files that exist on the webserver with the tracked files, without affecting untracked files. This is what would fail if we hadn't already made the .gitignore file
git checkout --track origin/master
Set up the Update Hook
In the Admin section of the repository, we add the URL of the deploy script to the "WebHook URLs" section. These are the post-receive hooks and each URL will be POSTed to when the repository is updated.