Git is a popular system for version management. It's pretty simple to install. In this guide, we'll see how we can install Git on Ubuntu 14.04.
We can install Git without having to add any repositories.
apt-get install git
Git works best if you give it some basic information: your name and your email address. You can set these options in Git with the following commands:
git config --global user.name "John Appleseed" git config --global user.email "email@example.com"
The whole idea of Git is committing, so you can see the changes in each commit. For example, these could be a couple of commits:
You can view these in Git.
First, create a directory for your project:
mkdir ~/git cd ~/git
Now create a couple of files, like:
touch example.html && touch index.html && touch contact.html
You can now start the process of making this a Git project by executing the
git init command while in the project directory:
cd ~/git git init
This will return the following response (assuming that
~/git refers to
Initialized empty Git repository in /home/test/git/.git/
Every time you create a new file and you want it to be included in Git, you need to tell Git that you want it to keep track of that file. For example, if we were to create a file called
calendar.php and we would want to add it to Git, we would type:
git add calendar.php
Assuming that you are in the same directory as where the file you want to add (
The problem with this is that you have to add each file manually. For example, if you already have a couple of files (in our case
contact.html), you would need to add these 3 manually. With 3 files, that isn't a huge task, but if you had more files, then it would take a considerable amount of time. Luckily, we can use
. which adds all files not currently in Git:
git add .
Congratulations, you're ready to commit! Committing is the process of telling Git you've made a number of changes and it should put them in the "changelog". After all, that's the whole point. In order to properly use commits, we must add a commit message. This allows you to keep track of all the changes. This can be anything you want; it's good practice to use something that you will understand though.
git commit -m "Initial commit" -a
Congratulations! You can now use Git on your VPS.