Git is Cool – and a Must – Introduction to Git

As most developers already know, submitting code to a version control system is an extremely crucial task. Many developers usually have a preferred version control system but today, I’m going to tell you why Git is cool – and a must. This article will primarily focus on the basics of Git and why you should use it (technical or creative). Future articles will dig deeper into how to use Git and how to implement it into your existing workflow.

Why Git?

Flexibility

When a user clones a project in Git, they have the ability to view the entire history for that project. Some other VC systems only allow users to view the latest code. Also, users have the ability to view the entire history, latest version, and update frequency among many other features inside of Git.

Offline Capabilities

Users can commit changes without being connected to a network. Once a user has cloned the project, they can keep working, updating and committing their changes without even being online. With Git, projects are saved inside of the local drive, therefore, allowing changes to be made without even being connected to a server.

Independence

Since Git is not a server-based program, every time a user clones a project, they automatically receive a local back up for that project. When a large team works together with different developers, everyone has a complete history and backup, therefore, eliminating the dependency on the center server.

Simplicity

Git does not create a backup for all individual files. Instead, it takes a snapshot for the files content only and puts all other collateral inside a .git folder. If at any point a user decides to stop using Git, they can simply delete the .git folder.

INSTALLING GIT

Go to http://git-scm.com and download the latest version of Git

  1. Install the ‘pkg’ package
  2. Drag ‘setup git PATH for non-terminal programs.sh’ into Terminal, click OK. (This will setup Git for non-terminal usage)
  3. Delete the Git dmg files

DEMO

Now that you have finished installation, let’s find out what Git is all about.

First, open Terminal. Next, check the Git version on your system to ensure you have installed Git correctly.

<br />git –version<br />

Now, let’s prepare a demo file. Create a folder on your desktop with an html page.

<br />cd desktop<br />mkdir demo<br />cd demo<br />touch index.html<br />

Now, you have a folder called “demo” on your desktop and inside the folder is an index.html page.

Intro to Git Commands

Create a new Git repository inside of the “demo” development folder

git init

Add files into the Git repository area. We need to tell Git that these files are going to be tracked. We can either add one file at a time, or enter “.” for all of the files. In this demo, I will add all of the files at once.

git add .

Next, view the files that are set to be committed. In this case, we only have one file: new file: index.html (or with .DS_Store in some case)

git status

Now, we are going to add a message and commit the file.

git commit –m ‘initial commit’

cchau

Written by Chris

Leave a Reply

*