Git Quick Start
2020-12-01

I began my GitHub journey with GitHub Desktop, a Git GUI client for Windows users. Recently, I switch to Git and find it worth to invest some time in learning it by using.

Quick Start for Git in Windows

  1. Download and install Git via this link https://git-scm.com/downloads

  2. Connect to GitHub using SSH keys

    With SSH keys, we can connect to GitHub without supplying your username and personal access token at each visit.

    • Learn more about SSH

    • Check for existing SSH keys

      Instruction page from GitHub Docs

      Novice Note:

      1. The physical directory in Windows is C:\Users\<user name>\.ssh\, where .ssh is a hidden folder by default
      2. Generate a new SSH key if needed
    • Add your SSH to the local ssh-agent and your GitHub account

      Novice Note:

      1. Use Git Bash to start the ssh-agent in the background. Command Prompt does not recognize eval command.

        1
        2
        3
        # start the ssh-agent in the background
        $ eval $(ssh-agent -s)
        > Agent pid <your pid number>
      2. Go to your GitHub setting page and follow this instruction from GitHub Docs

    • Test the SSH connection

      1
      2
      $ssh -T git@github.com
      > Hi <GitHub username>! You\'ve successfully authenticated, but GitHub does not provide shell access.
  3. Start a project with GitHub using the command line

    Instruction page from GitHub Docs

    Novice Note:

    1. We can interchangeably use Git Bash and Command Prompt in Windows

    2. My colleague suggests me use SSH instead of HTTPS when adding the URL for the remote repository

      1
      2
      3
      4
      # Sets the new remote
      $ git remote add origin <remote repository SSH URL>
      # Verifies the new remote URL
      $ git remote -v
    3. We can give a name to the origin branch

      1
      2
      # Pushes our local repository up to the remote repository we specify as the origin
      $ git push origin <branch name>

Git Reference

Cheat Sheet: https://training.github.com/downloads/github-git-cheat-sheet/

Video Tutorial: https://git-scm.com/videos

Documentation: https://git-scm.com/docs

My colleague, Jianghao, shares his note on using Git via this page: https://jianghaochu.github.io/version-control-with-git.html