Install Git Linux

Step 1 - Install Git

Ubuntu uses the apt package management system, which provides the command line utility apt-get and optional graphical interfaces such as Synaptic and Aptitude. We'll use apt-get to install packages, but if you're more comfortable with GUIs, those options are available. Open a terminal window on your local system and do the following:

  • Enter the following command to install Git:
    sudo apt-get install git<br />
            
    
  • Verify the installation was successful by typing which git at the command line.
    $which git
    /opt/local/bin/git<br />
            
    
  • Configure your username using the following command:
    git config --global user.name "<em>FIRST_NAME</em> <em>LAST_NAME</em>"
  • Configure your email address using the following command: git config --global user.email "MY_NAME@example.com"

Step 2 - Install Mercurial

Open a terminal window and do the following:

  • Make sure the universe repository is uncommented in the /etc/apt/sources.list file.
    To view the file, you can enter cat /etc/apt/sources.list at the command line. If the universe repo is uncommented the file contains a section similar to the following (example based on Ubuntu 10.10 Maverick Meerkat):
    deb //archive.ubuntu.com/ubuntu/ lucid universe
    deb-src //archive.ubuntu.com/ubuntu/ lucid universe 
    deb //archive.ubuntu.com/ubuntu/ lucid-updates universe
    deb-src //archive.ubuntu.com/ubuntu/ lucid-updates universe 
    deb //security.ubuntu.com/ubuntu/ lucid-security universe
    deb-src //security.ubuntu.com/ubuntu/ lucid-security universe
            
    

    If the lines are still commented (have a # prefix), then edit the file and uncomment them.

  • Make sure you have an updated package list by entering the following at the command line:
    sudo apt-get update
            
    
  • Enter the following command to install Mercurial:
    sudo apt-get install mercurial
            
    
  • Verify the installation was successful by typing which hg at the command line:
    $ which hg
    /usr/bin/hg
            
    


    Hg is the chemical symbol for Mercury and hg is the command for Mercurial.

  • If you don't already have one, create a file named .hgrc in your ~ (home) directory.
    This file is the Mercurial global configuration file.
  • Edit the ~/.hgrc file using your favorite editor.
  • Specify a username value.
    When you are done, the contents of the .hgrc configuration file look something like this:
    [ui]
    # Name data to appear in commits
    username = Mary Anthony <manthony@atlassian.com>
            
    
  • Save and close the file.