Getting Setup with Git

14 May 2023

My procedure for getting up and running with git

  1. Install Git: Open a terminal and type in the following command:

     sudo apt install git
    

    Verify the installation with:

     git --version
    

    This should show the installed Git version.

  2. Set up Git: Configure your email and username for Git, replace “you@example.com” and “your-username” with your email and username respectively:

     git config --global user.email "you@example.com"
     git config --global user.name "your-username"
    
  3. Generate a new SSH key: To clone private repositories, you need to authenticate with GitHub. One of the ways to do it is by using SSH keys. Here’s how you can generate a new SSH key:

     ssh-keygen -t ed25519 -C "you@example.com"
    

    Follow the prompts and press Enter to accept the default location and to use an empty passphrase. You can also use a passphrase if you’d like to.

  4. Add the SSH key to the ssh-agent: Start the ssh-agent in the background:

     eval "$(ssh-agent -s)"
    

    Add your SSH private key to the ssh-agent:

     ssh-add ~/.ssh/id_ed25519
    
  5. Add the SSH key to your GitHub account:
    • Copy the SSH public key to your clipboard:

        cat ~/.ssh/id_ed25519.pub
      
    • Go to GitHub, click on your avatar in the top right corner and go to ‘Settings’.
    • In the user settings sidebar, click on ‘SSH and GPG keys’.
    • Click on ‘New SSH key’, provide a title, paste your key into the ‘Key’ field and click ‘Add SSH key’.
  6. Clone the repository: Now you can clone the private repository. Replace ‘user’ and ‘repo’ with the username and the repository name:

     git clone git@github.com:user/repo.git
    
Top