Installing and configuring Git on Linux is a very straightforward process as Git was natively developed for the Linux platform. This guide will walk you through the steps to install and configure Git to begin developing using the Git version control system.
Git can be installed using automated package management utilities such as
yum, alternatively Git can also be compiled from source code.
Download the latest Git source package. Once downloaded open up your terminal and change into the directory where it was downloaded, then execute these commands.
# Extract the code: tar -xzvf git-* && cd git-* # Configure the source code for compilation: ./configure # Build and install: make && make install
Execute the following commands to install Git, based on your distribution (as root or using sudo).
# Debian/Ubuntu: apt-get install git-core
# Red Hat/Fedora: yum install git
Note: Depending on your release of Red Hat / Fedora, Git may not be available in the primary repository. If installing does not succeed, use the EPEL repository.
Creating SSH Keys
In terminal execute the following commands in order to generate a key pair.
# Change into home directory: cd ~ # Generate a key pair: ssh-keygen -t rsa
ssh-keygen you will be prompted for the location of the key pair, the default location (/home/$(whoami)/.ssh/id_rsa.pub) is sufficient. You will also be prompted for an optional pass phrase that will be required each time the key is used, while optional, it is highly recommended to setup a strong pass phrase for the key.
# Concatenate the key: cat ~/.ssh/id_rsa.pub
Now copy the key to your clipboard, your key should look like the following:
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAyyA8wePstPC69PeuHFtOwyTecByonsHFAjHbVnZ+h0dpomvLZxUtbknNj3+ c7MPYKqKBOx9gUKV/diR/mIDqsb405MlrI1kmNR9zbFGYAAwIH/Gxt0Lv5ffwaqsz7cECHBbMojQGEz3IH3twEvDfF6cu5p 00QfP0MSmEi/eB+W+h30NGdqLJCziLDlp409jAfXbQm/4Yx7apLvEmkaYSrb5f/pfvYv1FEV1tS8/J7DgdHUAWo6gyGUUSZ JgsyHcuJT7v9Tf0xwiFWOWL9WsWXa9fCKqTeYnYJhHlqfinZRnT/+jkz0OZ7YmXo6j4Hyms3RCOqenIX1W6gnIn+eQIkw== Mac Pro
In your Beanstalk account, the added SSH key will look like this:
Checking your connection
Before trying to access your Git remote repository, check if the connection to your remote hosted Git repository works. Enter the following command in the Terminal, replacing accountname with your account name:
In this case, this is the URL to access Git on your Beanstalk account. If you are using another version control hosting service, the URL would be provided by them.
You’ll most likely encounter a message that looks like this:
The authenticity of host 'accountname.beanstalkapp.com (22.214.171.124)' can't be established. RSA key fingerprint is 30:9a:97:f3:19:4f:d1:6e:28:76:9e:e7:d1:df:2c:31. Are you sure you want to continue connecting (yes/no)?
You can type
yes and press Enter, which will add your account’s hostname accountname.beanstalkapp.com to a
KNOWN_HOSTS file. This step won’t need to be repeated unless your public key or your account names changes. Also, this must be done from the Terminal.
If you were authenticated correctly, you will see a message similar to this one:
You were successfully authenticated as [emailaddress] in accountname.beanstalkapp.com. You can now continue to configure your local Git profile.
Setting up your Git Profile
After you have authenticated correctly by installing Git and setting up SSH keys, before you start using your Git repositories, you should setup your Git profile by typing following after you run Git bash in command line:
git config --global user.name "Firstname Lastname" git config --global user.email "firstname.lastname@example.org"
In case you are using Beanstalk for version control, it would be best if your first name, last name and email address match to the ones you use in your account to avoid any conflicts.
The easiest method to create a local repository is to clone the remote. This can be accomplished by performing the following through terminal.
git clone email@example.com:/repository-name.git
You should now have a repository directory named after your repository name. Now you can begin developing with using Git.
Linux GUI Client
Multiple Linux GUI based Git clients are available, your mileage may vary and using terminal is the preferred method.