What is Git?
Git is distributed version control software.
Version Control is the ability to save and track changes over time, without interfering with previous versions. As the software is distributed, it means all users can have a copy of an entire repository, containing all commits, branches, and files.
There are a few things you should know before we dive in:
- Branches are lightweight and cheap, so it’s OK to have many of them
- Git stores changes in SHA hashes, which work by compressing text files. That makes Git a very good version control system (VCS) for software programming, but not so good for binary files like images or videos.
- Git repositories can be connected, so you can work on one locally on your own machine and connect it to a shared repository. This way, you can push and pull changes to a repository and easily collaborate with others.
Why Use Git?
Version Control is important in development, whether for software, or simply for developing your automation scripts. Without it, you can risk losing your work. By using Git, you can make a “commit”, which is a snapshot of your point in time work. This provides you the capability to rollback to previous commits if needed.
Install the command line tool
# Executable Installers (all OSes) https://git-scm.com/downloads # Command Line Installer # Mac OS X brew install git # Linux sudo apt-get install git-all # Validate installation git version
Authenticating to GitHub and creating a repository
To make life easier, I am going to use GitHub as my main source control platform.
I am going to start off creating a repository on the GitHub website. This is simple to complete, so I will not document the steps, but you can view this page for more information.
I would also recommend at this point setting up the authentication with GitHub as well to your local CLI.
Cloning a Repository locally
Once our repository is created, we start off by cloning the repository locally.
git clone {url} #Example git clone https://github.com/saintdle/veducate-git-example.git
Create and commit our first file
Continue reading Exploring the Git command line – A getting started guide