Skip to content

Cheatsheet — Git & GitHub

Iankodj edited this page Apr 5, 2015 · 26 revisions

Using GitBash

Note: The tips below are tested under MS Windows.

Cloning

  • Using HTTPS

    With the HTTPS connection you will be prompted for your GutHub credentials when you clone, pull and push.

      git clone https://github.com/telerik/ajax-docs.git 
    
  • Using SSH

    As for SSH, you should create an SSH key and add it to your GitHub account. More detail are available in this GitHub article—Generating SSH keys.

      git clone git@github.com:telerik/ajax-docs.git
    

Generating SSH Keys

Information about that is available in this GitHub article—Generating SSH keys.

If there are complication head to the GitHub troubleshooting article on the matter—Error: Permission denied (publickey).

However, you can follow this steps to generate an SSH key:

  1. Generate a file with your ssh key (passphrase is optional, although, recommended):

     ssh-keygen -t rsa -C "your_email@example.com"
    
  2. Add your new key to the ssh-agent:

    1. Start ssh agent:

       ssh-agent -s
      

      or

       eval "ssh-agent -s"
      

      or

       eval "$(ssh-agent)"
      

      Tip: On my end, the eval "ssh-agent -s" and eval "$(ssh-agent)" always do the job.

    2. Add the key to the ssh agent:

      The file generated is available in the root folder, where GitBash has been started. Therefore, you need to use this file.

      Note: The generated files are two - [FileName] and [FileName].pub.

      	ssh-add [FileName]
      

      or

      	eval "ssh-add [FileName]"
      
  3. Add your ssh key to your GitHUb account:

    1. Remember the generated [FileName].pub file? Use the following command to copy the ssh key to your clipboard:

       clip < [FileName].pub
      
    2. Head to your GirHub account;

    3. Go to settings github-settings;

    4. Go to SSH Keys section;

      github-ssh-keys

    5. Press the Add SSH key button—github-add-ssh-key

    6. A form will appear below, type a title and paste the key in the textarea below:

      github-add-ssh-key-form

    7. Add the key by using the green Add key button below.

  4. Test the connection

     ssh -T git@github.com
    

Stage Files

Staging is used to prepare a commit or a stash.

  • Staging all changes

      git add -A	
    

    or

      git add --a
    

Clone this wiki locally