What is Git?

GitHub, GitBucket, GitLab. If you have spent any amount of time in the developer world, you have heard these terms. Git allows developers to store their files through snapshots. Each time a developer issues a commit (save), a snapshot of the data is saved. To prevent bloated storage and confusing projects, Git snapshots files that were changed and references previous files that are unchanged from a previous commit (fantastic for bug tracking).

Why Should I Use Git?

No matter how many people are working on a project, Git provides a safe and secure way of managing your data. Git allows developers to work on projects locally and commit (save) changes to the Git repository (storage location) when they want to make an update. Git takes the worry out of project management by providing a centralized location for all changes that have been made on a project.

If you are working with a team of developers, Git allows role-based access to the Git repository where other developers can contribute to the project. Developers will actively “pull” changes from the Git repository to get updates from other team members. When a team member is finished working on a particular part of the project, they will “push” their changes to the Git repository. By “pushing” data, a developer is sharing their work with other team members. By adding a comment to the commit, developers are able to communicate with other team members through the centralized Git repository (also great for project managers).

How Do I Start?

Create the Environment

To start using Git, you first must prepare your current development practice. To begin, you will need to install the developer tools needed to write and run the code you write on your local computer. In Hamilton, we develop all internal web-based software using a LAMP (Linux, Apache, MySQL, PHP) setup. To run a local LAMP setup on developer computers, we installed MAMP (Mac, Apache, MySQL, PHP). MAMP is a free, easy to install application that allows you to run a virtual server without having to manage Apache, MySQL, and PHP packages.

Use Windows??? – Check out WAMP.

Create a Git Repository

There are many options when choosing a Git repository. At Hamilton, we choose to run a private GitLab (free) which provided us with a stable, centralized location to share code among developers. Each service has it’s pros and cons, so check out the big three (GitHub, GitBucket, GitLab) before you make a decision. After you create a Git repository, each developer computer will need to create a SSH key to communicate with the Git service. The SSH key provides an authenticated, secure connection between your developer computers and the Git service. To create an SSH key, issue the following terminal command:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

To set your Git name (who will be recorded for an action), issue the following command via terminal.

git config --global user.name "Your Name"

Testing the Connection

Finally, we can now test our connection between our local development environment and the Git service. To test the connection using a terminal, issue the following command:

ssh -T [email protected]

Assuming you have created and added the SSH key correctly, you will received a welcome response from your Git service. You will now be able to use all Git functionality with your developer computer.

Final Thoughts

A Git service provides developers with a solid VCS (Version Control System) that tracks code progress and allows them to safely collaborate with other developers. Even if you are a solo developer, a Git service will allow you to integrate with Slack and other team communication tools to share your progress and collaborate with project managers. Take advantage of using Git service, you won’t regret it.