In this lesson, you will learn how to use git for version control and project management. If you do not have a Linux environment set up, visit: Setting up LAMP Lessons
Git is a method of version control. This means it helps you control and manage the constant changes that you will make to your code.
You can use Git to create a local repository (aka repo) for your project.
A git repository is basically a place to store your project. It is like a hidden directory.
Git files are stored and organized, simularly to Linux Files. Do you remember the Linux File System (Intro to Linux Video)? Git uses a simular system.
Git stores your files as either tree or blob objects. Trees are simular to Linux directories and blobs are simular to Linux files.
$ sudo apt-get install git-all
$ sudo dnf install git-all
To look up downloadss for your specific distro: git downloads
You probably want to set the git text editor to your favorite editor. I use vi/vim in my tutorials, so in the example below I am changing the editor to vim.
$ git config --global core.editor "vim"
$ git config --global user.name "candy66"
$ git config --global user.email codingcommanders@gmail.com
➼ config name
Put your name here
➼ config email
Put your email here.
First, you want to cd (change directory) to the directory that contains your project
Let's say your project is locatated in: /var/www/html/projects
$ cd /var/www/html/projects
➼ cd Change directory
➼ projects To the directory named projects.
projects is a subdirectory of html. html is a subdirectory of www and
www is a subdirectory of var. var is located in the root directory.
$ git init
➼ git init Creates
an empty repo
$ git add .
➼ git add
Updates the tree index and prepares for commit
➼ .
Add all files in current directory.
You can specify what file you want to add.
$ git add file.php
➼ git add
Updates the tree index and prepares for commit
➼ file.php
file.php is the file we are adding.
$ git commit
➼ git commit You will be prompted to enter a message regarding the version. Your git repo will be updated with the current version.
Here are more useful git commands!
$ git status
git status gives useful info about the files that you are preparing.
$ git log
git log shows you past commit dates and comments. See the example below.
$ git version
git version will tell you the installed version of git.
GitHub is a web based git repo. Using git will locally apply version control to your projects. GitHub provides an online backup of your versioning and allows you to connect with other developers/projects.
The code for Coding Commanders projects will be avilable on the Coding Commanders GitHub.
Purpose: In this assignment, we are preparing to begin out First
web application project.
Assignment:
1) Make the directory: /var/www/html/projects/datingApp
2) Inside datingApp, create a file called index.php or index.html
3) Create a git repo for this directory
4) Add index.html to your repo
5) Push the code to your GitHub account
What's next? In my next video, we will build an application that calculates someone's
datibility score!