
Let's assume that we have some great work ready in this folder. Here we should give the repository link and not the live folder. Tell Git to add a remote called 'live': git remote add live ssh:// repo/site.git Then we need to configure the remote path of our repository. You should change the path and name to whichever you choose. The 'post-receive' file will be looked into every time a push is completed and it's saying that your files need to be in /var/Local Machine With 'work-tree', you can define a different path to where your files will actually be transferred to. You can see on the documentation that 'git-dir' is the path to the repository. In order to execute the file, we need to set the proper permissions using: chmod +x post-receive When you finish typing, press 'control-d' to save. When you execute this command, you will have a blank line indicating that everything you type will be saved to this file. Now, create the file 'post-receive' by typing: cat > post-receive You will see a few files and folders, including the 'hooks' folder.

'Pre-receive' is executed as soon as the server receives a 'push', 'update' is similar but it executes once for each branch, and 'post-receive' is executed when a 'push' is completely finished and it's the one we are interested in.

Git documentation define three possible server hooks: 'pre-receive', 'post-receive' and 'update'.

This folder contains some sample files for possible actions that you can hook and perform custom actions set by you. Git repositories have a folder called 'hooks'. bare means that our folder will have no source files, just the version control. Login to your VPS from command line and type the following: What should we do if we want to push to site.git and at the same time make all the content available at /var/www/ ? Creating Our Repository Your server repository: /var/repo/site.git But you can also use Git to move your application to production. You have a local repository where you work and a remote repository where you keep everything in sync and can work with a team and different machines. When you use Git, the workflow generally is toward version control only.

I assume you already know how to create and use a repository on your local machine. While there are many ways to use Git to deploy our application, this tutorial will focus on the one that is most straightforward. This article will teach you how to use Git when you want to deploy your application. For an introduction to Git and how to install, please refer to the introduction tutorial.
