Using Git to Manage a Live Site

Uploading files to production level after every change in code can be quite a hassle. Most people would use an automated deployment system instead of doing it manually. We can create an automated deployment system ourself by just using a version control like Git, which would also only take a few seconds to set up.

This post outlines the exact steps on how to do that. You should be able to understand basic terminology like pushing or pulling.

Install Prerequisites

Install Git on the server- and client-side.

1
$ yum install git-core

Head to this page if you still don’t know how to install it.

Server Setup

You’ll want to start by creating a bare repository on your server. A folder without its actual source files. The repository should be set up somewhere outside of your web root. We are going to instruct Git where to put the actual files later. Once you decide on a location for your repository, go ahead and create the bare repository:

1
2
3
mkdir mysite.git
cd mysite.git
git init --bare

Now we need to instruct Git where to put the files after every commit. This can be done via hooks, basically actions defined by triggers.

Quick Introduction to C

C Preprocessor

C preprocessor code will be executed before compiling the actual c code.
Preprocessor lines start with # and do not end with a semicolon (in contrast to usual code instructions).

1
2
#define MAX_SIZE = 1
#undef MAX_SIZE

The first instruction replaces instances of MAX_SIZE with 1. The second instruction undefines the previous made call.

1
2
#include <stdio.h>
#include "myheader.h"

Tells the cpp to include stdio.h from the system libraries, where else the next line includes the header file myheader.h from the local directory.

1
2
3
4
5
6
7
#ifndef MAX_SIZE
...
#endif

#ifdef DEBUG
...
#endif

Pointers

A pointer points to a variable address/stores a variable address.

1
2
3
4
char val = 'c';
char val2;
char *pointer = &amp;val;
val2 = *pointer;

VHDL Snippets

Entity

1
2
3
4
5
6
7
8
entity ENTITY_NAME is
port(
i_a : in std_logic;
i_b : in std_logic;
i_c : in std_logic;
o_c : out std_logic
);
end entity;

Architecture

Processes run concurrent to each other.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
architecture ARCHITECTURE_NAME of ENTITY_NAME is
type states is (q0, q1, q2, q3);
signal state : states; -- end internal signals

begin
-- concurrent code
PROCESS_NAME : process(i_c) -- sensitivity list
begin
if rising_edge(i_c) then
-- sequential code
elsif falling_edge(i_c) then
-- sequential code
end if;
end process;
-- concurrent code
end architecture;

Process

1
2
3
4
5
6
process(c_in) is
begin
if (c_in='1') then
-- do something
end if;
end process;

Process (rising edge)

1
2
3
4
5
6
process(c_in) is
begin
if (c_in'event and c_in='1') then
-- do something
end if;
end process;